spechter
spechter

Reputation: 2368

Actions on Google - Account Linking process hits Token URL before Authorize URL?

We are trying to support the 'traditional' Account Linking flow as it seems the most general purpose, gives us a chance to surface T&C's, and we thought would be most bedded in.

But testing in the Assistant mobile app for starters, it fails for most users in our Actions app in Dev - After the user sees the Google-driven pop-up in the Assistant app with the "LINK ACCOUNTS" option - They tap that option, and our authorization screen does not appear.

Actions support have had a look at our Account Linking config and can't see any problems.

A couple of test users with newer Android phones DO see our Authorization screen, but the majority do not.

If we test the Authorization URL by pasting into a browser on the same device - It always displays just fine.

What is strange - If we look in our web server logs during the failed cases, the only hits we are seeing are to our 'TOKEN URL', whereas my understanding is a newly linking user should hit our 'Authorization URL' before ever hitting Token. The successful cases DO hit our Authorization URL first, as expected.

Feel free to pipe up if anyone can answer ANY of the following:

Any ideas what could be causing problems here?

Or ways we might investigate deeper?

Does an app need to be in Alpha testing, or anything like that before Account Linking works?

Is it normal/expected to hit the Token URL for a user that has never successfully linked accounts?

Can anyone confirm what the Token fetch response should be in that case? (Maybe we are not responding in a way that satisfies the other end)

Does anyone have a dummy/HelloWorld Account Linking web end-point we could test against? (Geeze that would be handy for the developer community!)

Upvotes: 1

Views: 156

Answers (1)

Prisoner
Prisoner

Reputation: 50731

I don't know exactly what is going on, but there are a couple of hints about what is happening and what avenue to investigate. I'm going to assume you're doing Account Linking with OAuth only. If you are doing a combination of "Google Sign In for Assistant and OAuth", that might change some things. To address some of your questions:

What could cause the Assistant to go to the Token Endpoint instead of the Auth endpoint?

It wouldn't go to the Token Endpoint unless it already had a Token. I could think of a few possible scenarios:

  • If it was going to Auth, getting a token since it was already authorized, so no window would pop up. (But you indicated it isn't going to that page.)

  • If the account in question is already authorized to the project via some other means. You can check https://myaccount.google.com/permissions to see if it is already authorized.

  • If you had tested it with this account previously and it has a token from then. If so, it should be listed at https://myaccount.google.com/permissions. Probably.

  • If you're not using the account you think you're using on the device in question.

How to investigate this?

Once you double-check some of the more obvious things (using the right account?):

  • Look at what is being sent to the Token endpoint
    • Does the token look familiar? Is it the same between calls? Same between different accounts?
    • Do you log tokens being issued? Can you?
    • What about the other information sent along with the token such as the client_id and client_secret?

Does it need to be in Alpha?

I'm not sure. Last I checked, it did not. I do think that it no longer works in the simulator, which is annoying, but doesn't require being in Alpha.

It does make it a little more difficult to check, however, since there is no Directory page that can tell you if the account is already linked. You'll need to go to the list of linked apps for the account to remove your app if it is: https://myaccount.google.com/permissions

Is this normal?

I wouldn't think so. It shouldn't hit the Token Endpoint unless it has an auth code or refresh token to exchange. It has to have that code/token from somewhere.

How should you respond?

If you get an auth code or refresh token that is invalid, or any of the other information provided at the token endpoint doesn't match what it should, you must return HTTP error code 400 "Bad Request" and include as the body the JSON

{"error": "invalid_grant"}

This should force it to go through reauth with the user.

Is there a public test server?

Auth0 isn't exactly public, but is free for basic use, and well suited for test purposes.

Upvotes: 1

Related Questions