簡體   English   中英

如何獲取 AccessToken

[英]How to get AccessToken

我正在構建一個客戶端,需要幫助來獲取訪問令牌。

想知道在grant_type 中需要傳遞什么? 客戶斷言? 從哪里獲得這些值? 因為在提供 AccessToken 的身份驗證中需要這些值

POST /token HTTP/1.1 主機::443 時間戳:1212669235 日期:2016 年 5 月 12 日星期五 17:21:16 GMT+0000 內容類型:application/x-www-form-urlencoded

grant_type=client_credentials&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&scope=profile-search&client_assertion=<JSON Web 簽名 (JWS)

HTTP/1.1 200 OK 內容類型:application/json;charset=UTF-8 內容長度:653 日期:2019 年 10 月 29 日星期二 14:13:29 GMT { "access_token": "KjdsjEeRFwksjqefindikHAfDKV...", "token_type ": "bearer" "expires_in": 3600 "scope":"profile-search" }

要獲取客戶端憑據類型 OAuth 機制的令牌,需要以下參數:

grant_type = client credentials
Access Token URL = <the Auth server URL token end point>
ClientId = <the Id from the auth server where app is registered>
ClientSecret = <value for the secret set>
Scope = <scope as defined for the application>

附上來自 Postman 的屏幕截圖,用於生成此授權類型的令牌的示例應用程序。

更多細節可以參考: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/

Azure AD 設置的示例在這里: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM