I am trying to run this official GCM Notifications sample. This comes with no instructions so trying to figure out on my own.
Here is what I did:
Registered an app on Google Dev Console, enabled APIs for Google+ API, Google Cloud Messaging for Android and Google Cloud Messaging for Chrome
I downloaded the repo and removed 'Key' field from the manifest.json
I uploaded it under my chrome app developers account
I installed this app. And opened the extension location and copied key field from manifest.json
Opened the Chrome app. Used the project id of app I registered on dev console as Sender ID. After pressing Register it said: 'Registration succeeded. Run the following command to send a message.'
Now it has three fields App Key, Message Key and Message Value. So in App key I entered key which I got from manifest.json and in both fields of Message Key and Message Value I entered Test and Hello world respectively.
It gave me a command like:
curl -H "Content-Type:application/x-www-form-urlencoded;charset=UTF-8" -H "Authorization: key=Mg...AB" -d "registration_id=AP...tQ" -d data.test=hello https://android.googleapis.com/gcm/send
When I run this from my local machine, I am getting following error:
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
The "Authorization: key" is not the key in the manifest.json file. It is the API key, which you get from the Developers Console. (Leave a comment if you can't find the API key, and I'll provide more detailed instructions.)
As the API has evolved into what is now the GCM API, the terminology has changed, and its usage by Google is inconcistent.
Related
I am a beginner in Microsoft BOT Development. I am trying to create a BOT Application that sends proactive messages to connected users. I got a GitHub repo source code.
I have already created an app in the Azure portal and used these credentials to the local development environment and use Bot Emulator for connecting the BOT application. Everything works fine in the local environment, I can connect the BOT Emulator with the local development environment. After the deployment (deployment documentation URL) I can't connect the BOT through Emulator it always shows a message, Cannot post activity unauthorized
I already copied the AppID and Password to the '.env' file. This AppID and Password works fine in the local development. Is there any additional configuration needed to connect the BOT after the deployment?
In the local emulator, it would run without AppID and Password as well unless you are communicating with any external resources e.g. LUIS, QnA service etc.
Make sure that AppID & Password you are supplying are correct by running the below CURL command (replace with your AppId & Secret). If it is correct, you would see the token being generated successfully.
curl -k -X POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token -d "grant_type=client_credentials&client_id=APP_ID&client_secret=APP_PASSWORD&scope=https%3A%2F%2Fapi.botframework.com%2F.default"
https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0&tabs=csharp#step-2
If the secret is incorrect, follow this to regenerate.
If the above works fine, and you see the token being generated, and if your Bot code is deployed on Azure, you can also add the Bot AppID and Password in App service configuration. Something like this -
{
"name": "MicrosoftAppId",
"value": "xxxx-xxxx-xxxx-xxxx-xxxx",
"slotSetting": false
},
{
"name": "MicrosoftAppPassword",
"value": "xxxx",
"slotSetting": false
},
If you are storing Bot secret in Key Vault, you can retrieve from there as well.
https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-authentication?view=azure-bot-service-4.0&tabs=csharp%2Caadv2#azure-key-vault
I'm getting backend failure error in google smart home while accessing fulfillment URL provided in dialogflow webhook url
{
textPayload: "SYNC: Request ID 1570058940383905256 failed with code: BACKEND_FAILURE"
insertId: "1trptjqgc2uhm9d"
resource: {
type: "assistant_action"
labels: {
action_id: "SMART_HOME_SYNC"
project_id: "gnextsmarthome"
version_id: ""
}
}
Action console Account linking details:
Authorization URL: https://accounts.google.com/o/oauth2/auth
Token URL :https://oauth2.googleapis.com/token
through voice assistant able to access fulfillment url successfully,but failed to access through google home while linking app.
also prebuilt smart home action option not visible in Action menu
I referred to this example to build smart home app:
https://github.com/shivasiddharth/google-actions-smarthome
In that example,they had used fake access token and auth url.
In order to use google signin concept, I have added google account token url: https://accounts.google.com/o/oauth2/auth and then end up with error 'Google account error'.(fig 1)
enter image description here
and also account linking type option is missing.but in this case able to see smart home prebuilt action(fig 2)
enter image description here
But later i noticed account linking type option become visible after enabling with dialogflow api.then 'google account error' is gone.
enter image description here
in this case i have mentioned fulfillment url in dialogflow webhook address to trigger smart home backend server function.
enter image description here
enter image description here
enter image description here
You are trying to use an endpoint which can’t be used and hence you will have to use your own endpoints as also mentioned in the comments on this answer. You can try out the Connect smart home devices to the Google Assistant codelab to see if the error is due to a configuration, or the server you are running behind your endpoint.
If you are still running into issues when implementing your own fulfillment endpoint, you can take a look at your error logs to see what the detailed debug string comes out as. You can learn more from the Troubleshooting Guide.
I have a Chrome Extension that needs to authenticate the user. Once authenticated, I will send that user's email to my server running in Docker and then log them in. I am having trouble getting the token. Here is the code:
chrome.identity.getAuthToken({ 'interactive': true }, function(token) {
if (chrome.runtime.lastError) {
currentSessionAccessToken=token;
alert(chrome.runtime.lastError.message);
//alert("you need to have a gmail account"); //ubuntu
return;
}
currentSessionAccessToken=token;
var x = new XMLHttpRequest();
x.open('GET', 'https://www.googleapis.com/oauth2/v2/userinfo?alt=json&access_token=' + token);
x.onload = function() {
if (x.readyState=200)
{
var data=this.responseText;
jsonResponse = JSON.parse(data);
photo = jsonResponse.picture;
szName=jsonResponse.name;
email=jsonResponse.email;
x.abort(); //done so get rid of it
send_to_backend(request, sender, sendResponse);
};
}
x.send();
}
The problem is that I am not getting back an access token. The backend (at this time) is also on my laptop (localhost) but in a docker container. I don't have an SSL cert for my localhost and I am wondering if that is the issue? I am never getting a token so I never get to send it with the XMLHttpRequest, and thus I never get a ReadyState=200. Any idea what is wrong?
Did you register your app for Google OAuth API access and designate the oauth field in the manifest?
From the documentation on user auth:
Copy key to your manifest
When you register your application in the Google OAuth console, you'll provide your application's ID, which will be checked during token requests. Therefore it's important to have a consistent application ID during development.
To keep your application ID constant, you need to copy the key in the installed manifest.json to your source manifest. It's not the most graceful task, but here's how it goes:
Go to your user data directory. Example on MacOs: ~/Library/Application\ Support/Google/Chrome/Default/Extensions
List the installed apps and extensions and match your app ID on the apps and extensions management page to the same ID here.
Go to the installed app directory (this will be a version within the app ID). Open the installed manifest.json (pico is a quick way to open the file).
Copy the "key" in the installed manifest.json and paste it into your app's source manifest file.
Get your OAuth2 client ID
You need to register your app in the Google APIs Console to get the client ID:
Login to the Google APIs Console using the same Google account used to upload your app to the Chrome Web Store.
Create a new project by expanding the drop-down menu in the top-left corner and selecting the Create... menu item.
Once created and named, go to the "Services" navigation menu item and turn on any Google services your app needs.
Go to the "API Access" navigation menu item and click on the Create an OAuth 2.0 client ID... blue button.
Enter the requested branding information, select the Installed application type.
Select Chrome Application and enter your application ID (same ID displayed in the apps and extensions management page).
Once you register your app you need to add something like this to your manifest:
"oauth2": {
"client_id": "YOUR_CLIENT_ID",
"scopes": ["scope1", ...]
}
Turns out that in order to get "identity" working you must publish to the Google WebStore. The reason I stayed away from that is that it often takes weeks to get a site reviewed. I have had that experience in the past. I haven't really nailed down the new URL that will be using and wanted to get the system working before I did that. Now that I submitted for Review, I guess I have some time, and will "dummy up" the steps needed (ie authentication) to continue the development work. Thanks Micah for pointing out the manual. This led to me realizing that there is no way to get "identity" working without getting approval from Google.
I've created a simple template like in the demos:
<!DOCTYPE html>
<html>
<head>
<title>Add your title here</title>
</head>
<body>
<h1>My B2C Application</h1>
<div id="api"></div> <!-- Leave this element empty because Azure AD B2C will insert content here. -->
</body>
</html>
This is a file hosted on my App Service at:
https://<mydomain>.azurewebsites.net/html.signin.html
I've created a B2C tennent and that is all working. In my Signup Signin policy (B2C_1_aa-signup-signin)
I've setup the custom page url to:
https://<mydomain>.azurewebsites.net/html.signin.html
However, even just clicking on the Signup button on my site returns an error:
Error. An error occurred while processing your request.
Request ID: |258cfa9e-4dab035257ed702a. Development Mode
Swapping to Development environment will display more detailed
information about the error that occurred.
Development environment should not be enabled in deployed
applications, as it can result in sensitive information from
exceptions being displayed to end users. For local debugging,
development environment can be enabled by setting the
ASPNETCORE_ENVIRONMENT environment variable to Development, and
restarting the application.
I've setup CORS in my .NET Core 2.1 application with:
services.AddCors();
And:
app.UseCors(opt =>
{
opt.WithOrigins("https://<b2c-tennent-name>.b2clogin.com")
.AllowAnyHeader()
.AllowAnyMethod();
});
From all I've read, this is all I should have to do. I've been looking to try and find any CORS settings on my web sites App Service but I can't see anything relevant.
My site config is:
"AzureAdB2C": {
"Instance": "https://<b2c-tennent-name>.b2clogin.com/tfp/",
"ClientId": "<my id>",
"CallbackPath": "/signin-oidc",
"Domain": "<b2c-tennent-name>.onmicrosoft.com",
"SignUpSignInPolicyId": "B2C_1_aa-signup-signin",
"ResetPasswordPolicyId": "B2C_1_aa-password-reset",
"EditProfilePolicyId": "B2C_1_aa-profile-edit"
},
I've also enabled App Insights on my web app but I can't even seem to get a handle on an error message to solve.
I guess I have two questions.
What should I check configuration wise next?
And how do I find out what the error is? Azure seems completely opaque on this topic. I've no idea of the error at all.
Until I get identify the problem I'm completely shooting in the dark. As far as I can tell the only way I have deviated from the docs is that my html file is hosted on my App Service which from this document is a completely legitimate place to host it.
This write up describes exactly what I've done yet I my login is completely broken.
After digging around the requests I've found this hidden in an OK 200 response:
AADB2C90006: The redirect URI 'http://<my-app-service>.azurewebsites.net/signin-oidc' provided in the request is not registered for the client id 'b850cee0-f723-47fd-8f2e-c1fa1ec21038'.
But you can only register https reply URLs so how do I fix this?
Register your reply url with HTTPS: https://<my-app-service>.azurewebsites.net/signin-oidc. Azure app services hosted under the azurewebsites.net domain provide a built-in SSL certificate.
I'm trying to authorize with chrome.identity.getAuthToken() to get token for Picasa web service. I couldn't find Picasa API in Google Developer Console and set its scope to "https://picasaweb.google.com/data/" oauth2 part of manifest.json. Picasa docs say that I can skip this step.
chrome.identity.getAuthToken({
interactive: true
}, function (token) {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
} else {
console.log(token);
}
});
getAuthToken() always ends with an error "OAuth2 request failed: Service responded with error: 'bad client id: {0}'". If no scopes are set, the error looks like "OAuth2 request failed". Where have I mistaken?
Steps I take to make it work
Go to Google Developers Console and create a new project.
Go to APIs & auth > Credentials in the panel to create new Client ID. The application ID of chrome app can be obtained from Chrome Developer Dashboard if you your app is uploaded.
Go to APIs & auth > Consent screen and fill in Email Address and Product Name and Save.
I didn't know step 3 was necessary.
It seems amazing but after 1 day has passed, everything is working :)
UPD: I've tried gdrive sample from chrome-app-samples repo and added scope for Picasa. After everything worked fine, I copied its key and oauth2 section to my app's manifest. Everything worked fine too. After this I deleted client_id for app in developer console and created it again. And after that everything was ok.
You need to register your application in Google Developer Console and obtain a client_id. See the 'Credentials' pane to configure your application.