如何使用 oauth.tools 获取 Google Web 应用程序的令牌? [英] How do I get tokens for a Google Web application using oauth.tools?

查看:32
本文介绍了如何使用 oauth.tools 获取 Google Web 应用程序的令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用

解决方案

为此,您需要:

  1. 在 Google 上配置客户端(上面的屏幕截图)
  2. 在 OAuth.tools 中设置环境以与 Google 的身份平台进行通信
  3. 执行代码流程

首先,应将 Web 应用程序的 origins 设置为 https://oauth.tools.redirect URIs 应设置为 https://oauth.tools/callback/code.

创建客户端后,记下其客户端 ID 和密码.稍后您将需要它们来配置 OAuth.tools.

接下来,在 OAuth.tools 中,创建一个新环境:

Issuer 字段中,输入 https://accounts.google.com/ 并点击 Refresh.这将填充

接下来,在 Client 选项卡上,单击 + New client.然后,输入您记下的 Google 客户端的 Client ID.也设置秘密并打开代码流:

关闭那个模态,然后创建一个新的流程:

选择代码流:

在环境下拉菜单中,确保选择了您创建的那个:

Client ID 文本组合框中,选择您在环境中创建的那个.选择 openid 或输入它并按回车键.点击运行按钮:

如果系统提示,请登录 Google 并同意使用该应用.

最后,在您返回 OAuth.tools 后,点击第 3 步旁边的Redeem Code:

在右侧的结果窗格中,您将看到访问令牌和 ID 令牌.

如果您还需要刷新令牌,请查看此答案,其中详细介绍了 如何从 Google 获取刷新令牌.

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:

解决方案

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.

这篇关于如何使用 oauth.tools 获取 Google Web 应用程序的令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆