How do I get tokens for a Google Web application using oauth.tools?

不想你离开。 提交于 2021-01-29 10:02:06

问题


I would like to use OAuth.tools to get an access token, refresh token, and ID token for my Web application that I've setup in Google Identity Platform? I'm unsure how to configure OAuth.tools to communicate with Google's OAuth server, and there are various flows, but I'm not sure which applies to my Web application. What should I fill in here, for instance, to make it work with OAuth.tools:


回答1:


To do this, you need to:

  1. Configure the client at Google (the screenshot above)
  2. Setup an environment in OAuth.tools to be able communicate with Google's identity platform
  3. Perform the code flow

First, the origins of the Web application should should be set to https://oauth.tools. The redirect URIs should be set to https://oauth.tools/callback/code.

After you create the client, take note of its client ID and secret. You'll need them later to configure OAuth.tools.

Next, in OAuth.tools, create a new environment:

In the Issuer field, enter https://accounts.google.com/ and click Refresh. This will populate all of the endpoints from the Google discovery document. You can give the environment a nice name too if you want:

Next, on the Client tab, click + New client. Then, enter the Client ID of the Google client you took note of. Set the secret as well and toggle on Code Flow:

Close that modal, and then create a new flow:

Select Code Flow:

In the environment dropdown, make sure the one you created is selected:

In the Client ID text combobox, pick the one you created in the environment. Select openid or type it and hit enter. Click the Run button:

Login at Google and consent to the app if you're prompted to.

Finally, after you get back to OAuth.tools, hit Redeem Code next to step 3:

In the result pane on the right, you'll see the access token and ID token.

If you want a refresh token as well, checkout this answer that explains more about how to obtain a refresh token from Google.



来源:https://stackoverflow.com/questions/63657207/how-do-i-get-tokens-for-a-google-web-application-using-oauth-tools

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