Google Actions SDK Sign-In implicit flow

南笙酒味 提交于 2019-12-11 12:03:17

问题


EDIT: On phone assistant its working now problem just exist in google action simulator

I just try to setup Google Actions SDK account Linking with implicit grant and try to test it in Simulator.

First question is this even possible in Simulator?

  1. To Do so I added at the action console account linking with the type implicit grant to my action.
  2. The url I used is working.
  3. Now I added a signup request to my action. For testing so if I write signup in simulator the server response with:

{ conversationToken: JSON.stringify(state), expectUserResponse: true, expectedInputs: [ { inputPrompt: { initialPrompts: [ { textToSpeech: "PLACEHOLDER_FOR_SIGN_IN" } ], noInputPrompts: [] }, possibleIntents: [ { "intent": "actions.intent.SIGN_IN", "inputValueData": {} } ], speechBiasingHints: [] } ] }

  1. After this the server didn't request the sign in page route (the address is correct!). It just responds with SignIN intent ERROR :

{ "isInSandbox'": false, "surface": { "capabilities": [ { "name": "actions.capability.AUDIO_OUTPUT" }, { "name": "actions.capability.SCREEN_OUTPUT" } ] }, "inputs": [ { "rawInputs": [ { "query": "i think so", "inputType": "VOICE" } ], "arguments": [ { "name": "SIGN_IN", 'extension': { "@type": "type.googleapis.com/google.actions.v2.SignInValue", "status": "Error" } } ], "intent': "actions.intent.SIGN_IN" } ], "device": { "locale": "en-US" }, "conversation": { "conversationId": "1494606917128", "type": "ACTIVE", "conversationToken": "[\"_actions_on_google_\"]" } }

Why? Where is the problem? Can I see a error message somewhere?

Here is what happen in the simulator between 3 and 4:


回答1:


Is it same when you use the phone app? For me it opens an embedded browser with my /auth endpoint, which the simulator doesn’t do.




回答2:


I am able to make it WORKING after a long time. We have to enable the webhook first and we can see how to enable the webhook in the dialog flow fulfillment docs If we are going to use Google Assistant, then we have to enable the Google Assistant Integration in the integrations first. Then follow the steps mentioned below for the Account Linking in actions on google:-

  1. Go to google cloud console -> APIsand Services -> Credentials -> OAuth 2.0 client IDs -> Web client -> Note the client ID, client secret from there -> Download JSON - from json note down the project id, auth_uri, token_uri -> Authorised Redirect URIs -> White list our app's URL -> in this URL fixed part is https://oauth-redirect.googleusercontent.com/r/ and append the project id in the URL -> Save the changes

  2. Actions on Google -> Account linking setup 1. Grant type = Authorisation code 2. Client info 1. Fill up client id,client secrtet, auth_uri, token_uri 2. Enter the auth uri as https://www.googleapis.com/auth and token_uri as https://www.googleapis.com/token 3. Save and run 4. It will show an error while running on the google assistant, but dont worry 5. Come back to the account linking section in the assistant settings and enter auth_uri as https://accounts.google.com/o/oauth2/auth and token_uri as https://accounts.google.com/o/oauth2/token 6. Put the scopes as https://www.googleapis.com/auth/userinfo.profile and https://www.googleapis.com/auth/userinfo.email and weare good to go. 7. Save the changes.

  3. In the hosting server logs, we can see the access token value and through access token, we can get the details regarding the email address.

  4. Append the access token to this link "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" and we can get the required details in the resulting json page.
  5. accessToken = req.get("originalRequest").get("data").get("user").get("accessToken")
    r = requests.get(link) print("Email Id= " + r.json()["email"]) print("Name= " + r.json()["name"])

P.S. You can use the Grant Type as Implicit also instead of Authorisation code.



来源:https://stackoverflow.com/questions/47396535/google-actions-sdk-sign-in-implicit-flow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!