我曾嘗試使用以下信息創建的OAuth 2.0遊樂場的訪問令牌:爲什麼只有OAuth 2.0 Playground訪問令牌適用於Google API?
選擇&授權的API:https://www.googleapis.com/auth/consumersurveyshttps://www.googleapis.com/auth/userinfo.email
這工作(對我來說它返回一個列表我之前創建的調查)。
但是,當我使用Postman創建訪問令牌或從AspNetUserClaims表中檢索它們時,這些訪問令牌不起作用。
示例#1:我在Postman中爲Google獲得一個訪問令牌,並將其添加到Header(對於承載和令牌顯示覆選標記)。我按Postman中的Send並返回「Invalid_Credentials」。如果令牌過期或無效,我將其刪除並在頭中創建一個新的令牌。仍然失敗。
POSTMAN info:
Auth URL: https://accounts.google.com/o/oauth2/auth
Access Token URL: https://accounts.google.com/o/oauth2/token
Client ID: hidden
Client Secret: hidden
Scope: https://www.googleapis.com/auth/userinfo.email
Grant Type: Authorization Code
Request access token locally is checked.
例2:我用它生成一個訪問令牌,然後存儲在AspNetuserClaims表我開發的網站上的谷歌點登錄按鈕。我將該訪問令牌複製到Postman(也出現複選標記)並按發送,並且它還返回「Invalid_Credentials」。如果令牌過期,我從所有AspNet用戶表中刪除新創建的帳戶和訪問令牌,然後再次嘗試。仍然失敗。
爲什麼只能在Postman中使用OAuth 2.0 Playground令牌?它們都是通過郵遞員令牌嚮導或新註冊的用戶帳戶或OAuth2.0 Playground嚮導新生成的令牌,但只有OAuth2.0 Playground令牌實際上可以工作...