简体   繁体   English

OAuth 2.0 授权 Header

[英]OAuth 2.0 Authorization Header

I want to develop a SDK that encapsules the OAuth 2.0 functions.我想开发一个封装了 OAuth 2.0 函数的 SDK。 I have checked the differences between OAuth 1.0 & 2.0, and I have some confusion on Authorization Header ( 1.0 and 2.0 ), OAuth 1.0 protocol parameters can be transmitted using the HTTP "Authorization" header, but I can't find this described in current OAuth 2.0 draft.我已经检查了 OAuth 1.0 和 2.0 之间的差异,我对授权 Header( 1.02.0 )有些困惑,OAuth 1.0 协议参数可以使用 HTTP“授权”88185300 传输,80658 中描述但当前无法找到它OAuth 2.0 草案。

Does OAuth 2.0 supports authorization headers? OAuth 2.0 是否支持授权标头?

In OAuth 1.0 your header would look like:在 OAuth 1.0 中,您的 header 看起来像:

Authorization: OAuth realm="Example",
    oauth_consumer_key="0685bd9184jfhq22",
    oauth_token="ad180jjd733klru7",
    oauth_signature_method="HMAC-SHA1",
    oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",
    oauth_timestamp="137131200",
    oauth_nonce="4572616e48616d6d65724c61686176",
    oauth_version="1.0"

对于那些寻找如何在标头中传递OAuth2授权(访问令牌)的示例(与使用请求或body参数相反),以下是它的完成方式:

Authorization: Bearer 0b79bab50daca910b000d4f1a2b675d604257e42

You can still use the Authorization header with OAuth 2.0. 您仍然可以在OAuth 2.0中使用Authorization标头。 There is a Bearer type specified in the Authorization header for use with OAuth bearer tokens (meaning the client app simply has to present ("bear") the token). 授权标头中指定了一个承载类型,用于OAuth承载令牌(意味着客户端应用只需要呈现(“承担”)令牌)。 The value of the header is the access token the client received from the Authorization Server. 标头的值是客户端从授权服务器接收的访问令牌。

It's documented in this spec: https://tools.ietf.org/html/rfc6750#section-2.1 它在此规范中有记录: https//tools.ietf.org/html/rfc6750#section-2.1

Eg: 例如:

   GET /resource HTTP/1.1
   Host: server.example.com
   Authorization: Bearer mF_9.B5f-4.1JqM

Where mF_9.B5f-4.1JqM is your OAuth access token. 其中mF_9.B5f-4.1JqM是您的OAuth访问令牌。

I just want to specify that you can use "Property Expansion" in the header value as well to Automation your proccess.我只想指定您也可以在 header 值中使用“Property Expansion”来自动化您的过程。

( Actually i use a property transfer too, to transfer token into my TestSuite property and then as you can see return it with "${#TestSuite#token}" ) (实际上我也使用属性转移,将令牌转移到我的 TestSuite 属性中,然后如您所见,用“${#TestSuite#token}”返回它)

example:例子:

财产支出

Sources:资料来源:

Best regards community !最好的问候社区!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM