如何获得用于 api 测试的 Google OAuth 2 令牌
How to get a Google OAuth 2 token for api testing
我正在尝试构建一个使用 google OAuth 2.0 来验证端点的简单节点 API,我正在尝试通过调用 Postman 来测试它,但我不知道如何为我的 google 帐户获取 OAuth 令牌,以便在调用 API 时使用。我尝试在 Postman 中使用 OAuth 功能,但无法正确配置它。谁能给我任何关于如何获得我可以使用的令牌或正确使用 Postman/any 其他实用程序来进行此测试的指导?
以下是 Google's Sign-In button template to initialize the login & grant of permissions process (provided the project is set up in the Google Developer Console):
的使用方法
<meta name="google-signin-client_id" content="{{ OAUTH2_CLIENT_ID }}">
<script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>
<div id="google-signin-button"
class="g-signin2"
data-width="170"
data-height="30"
data-onsuccess="onSignIn"
data-onfailure="onSignInFailure">
</div>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
var idToken = googleUser.getAuthResponse().id_token;//this is your token
}
我正在尝试构建一个使用 google OAuth 2.0 来验证端点的简单节点 API,我正在尝试通过调用 Postman 来测试它,但我不知道如何为我的 google 帐户获取 OAuth 令牌,以便在调用 API 时使用。我尝试在 Postman 中使用 OAuth 功能,但无法正确配置它。谁能给我任何关于如何获得我可以使用的令牌或正确使用 Postman/any 其他实用程序来进行此测试的指导?
以下是 Google's Sign-In button template to initialize the login & grant of permissions process (provided the project is set up in the Google Developer Console):
的使用方法<meta name="google-signin-client_id" content="{{ OAUTH2_CLIENT_ID }}">
<script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>
<div id="google-signin-button"
class="g-signin2"
data-width="170"
data-height="30"
data-onsuccess="onSignIn"
data-onfailure="onSignInFailure">
</div>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
var idToken = googleUser.getAuthResponse().id_token;//this is your token
}