简体   繁体   English

如何获取 AccessToken

[英]How to get AccessToken

I am building a client and need help getting the access token.我正在构建一个客户端,需要帮助来获取访问令牌。

would like to know what needs to be passed in grant_type?想知道在grant_type 中需要传递什么? client_assertion?客户断言? Where to get these values from?从哪里获得这些值? as these values are required in Authentication in providing AccessToken因为在提供 AccessToken 的身份验证中需要这些值

POST /token HTTP/1.1 Host: :443 Timestamp: 1212669235 Date: Fri, 12 May 2016 17:21:16 GMT+0000 Content-type: application/x-www-form-urlencoded 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 Signature (JWS)> 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 Content-Type: application/json;charset=UTF-8 Content-Length: 653 Date: Tue, 29 Oct 2019 14:13:29 GMT { "access_token": "KjdsjEeRFwksjqefindikHAfDKV...", "token_type": "bearer" "expires_in": 3600 "scope":"profile-search" } 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" }

To get the token for Client Credentials type OAuth mechanism, following parameters are needed:要获取客户端凭据类型 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>

Attaching the screenshot from Postman for a sample application to generate the token for this grant type.附上来自 Postman 的屏幕截图,用于生成此授权类型的令牌的示例应用程序。

More details for it can be referenced from: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/更多细节可以参考: https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/

Sample for this from Azure AD set up is here: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow 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.

相关问题 如何从Orange Message API获取AccessToken - How To Get AccessToken From Orange Message Api 静默获取微软 accessToken - Get Microsoft accessToken silently 如何将角色声明包含到访问令牌中? - How include roleclaim to accesstoken? 获取对我的 Paypal AccessToken 的请求 - Get request for my Paypal AccessToken 如何获取Twitter的AccessToken和AccessTokenSecret? - How to Obtain AccessToken and AccessTokenSecret for Twitter? 如何使用Firebase获取Oauth accessToken和OAuth密码以在Unity C#中对Twitter进行身份验证 - How to get the Oauth accessToken and OAuth secret for authentication to Twitter in Unity C# using Firebase 如何在 WinUI 3 应用程序中获取 AccessToken 或 Session 字符串以启动 AWS Cognito MFA 的设置 - How to get AccessToken or Session string in WinUI 3 application to initiate set up of AWS Cognito MFA 如何从 MSTest c# 代码中获取我的 Azure 应用服务的 accessToken - How to get accessToken to my Azure App Service from inside MSTest c# code 如何使用C#获取OAuth AccessToken(google)以将作业发布到Google Hire? - How to get OAuth AccessToken (google) for posting a job to Google Hire in C#? 从Owin Api创建后,你如何获得Oauth2 AccessToken? - How do you get the Oauth2 AccessToken after its creation from the Owin Api?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM