带有基本 POST 请求的 OAuth 令牌
OAuth token with basic POST request
我需要使用简单的 POST 请求获取 OAuth 令牌。
在 Postman 中,我们通过以下配置配置 OAuth 令牌:
当我单击“获取新访问令牌”时,邮递员对访问令牌发出请求URL。
如何看待该请求的样子?这些参数(client id、client secret 等)是否放在 POST body 中? headers 是什么?我想以纯文本形式查看请求结构。
基本上我需要在脚本中模拟这个请求,我必须在 body 本身中包含凭据,其中 body 看起来像这样:
{
"Access_Token_URL":"myURL",
"Client_ID":"myClientId",
"Client_Secret":"myClientSecret",
"Scope":"myScope"
}
该请求遵循 OAuth 2.0 specification, using the client_credentials
grant,它将使用授权基础 header 来验证客户端;所以它的 body 看起来像这样:
POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic bXlDbGllbnRJZDpteUNsaWVudFNlY3JldA
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=MyScope
其中 bXlDbGllbnRJZDpteUNsaWVudFNlY3JldA
是 myClientId:myClientSecret
的 Base64 编码值。
请注意 Content-Type 是 application/x-www-form-urlencoded
。
另请注意,Postman 所说的 Access Token URL 在 OAuth 2.0 术语中实际上被命名为 Token Endpoint。
我需要使用简单的 POST 请求获取 OAuth 令牌。
在 Postman 中,我们通过以下配置配置 OAuth 令牌:
当我单击“获取新访问令牌”时,邮递员对访问令牌发出请求URL。
如何看待该请求的样子?这些参数(client id、client secret 等)是否放在 POST body 中? headers 是什么?我想以纯文本形式查看请求结构。
基本上我需要在脚本中模拟这个请求,我必须在 body 本身中包含凭据,其中 body 看起来像这样:
{
"Access_Token_URL":"myURL",
"Client_ID":"myClientId",
"Client_Secret":"myClientSecret",
"Scope":"myScope"
}
该请求遵循 OAuth 2.0 specification, using the client_credentials
grant,它将使用授权基础 header 来验证客户端;所以它的 body 看起来像这样:
POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic bXlDbGllbnRJZDpteUNsaWVudFNlY3JldA
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=MyScope
其中 bXlDbGllbnRJZDpteUNsaWVudFNlY3JldA
是 myClientId:myClientSecret
的 Base64 编码值。
请注意 Content-Type 是 application/x-www-form-urlencoded
。
另请注意,Postman 所说的 Access Token URL 在 OAuth 2.0 术语中实际上被命名为 Token Endpoint。