What is the OAuth 2.0 Bearer Token exactly?

后端 未结 4 1139
独厮守ぢ
独厮守ぢ 2020-11-28 17:47

According to RFC6750-The OAuth 2.0 Authorization Framework: Bearer Token Usage, the bearer token is:

A security token with the property that any party

4条回答
  •  鱼传尺愫
    2020-11-28 17:56

    Bearer token is one or more repetition of alphabet, digit, "-" , "." , "_" , "~" , "+" , "/" followed by 0 or more "=".

    RFC 6750 2.1. Authorization Request Header Field (Format is ABNF (Augmented BNF))

    The syntax for Bearer credentials is as follows:
    
         b64token    = 1*( ALPHA / DIGIT /
                           "-" / "." / "_" / "~" / "+" / "/" ) *"="
         credentials = "Bearer" 1*SP b64token
    

    It looks like Base64 but according to Should the token in the header be base64 encoded?, it is not.

    Digging a bit deeper in to "HTTP/1.1, part 7: Authentication"**, however, I see that b64token is just an ABNF syntax definition allowing for characters typically used in base64, base64url, etc.. So the b64token doesn't define any encoding or decoding but rather just defines what characters can be used in the part of the Authorization header that will contain the access token.

    References

    • RFC 5234 3.6. Variable Repetition: *Rule
    • RFC 2616 2.1 Augmented BNF

提交回复
热议问题