What are the characteristics of an OAuth token?

后端 未结 7 1995
谎友^
谎友^ 2021-02-04 00:52

How many characters long can an oauth access token and oauth access secret be and what are the allowed characters? I need to store them in a d

相关标签:
7条回答
  • 2021-02-04 01:15

    Valid chars for OAuth token are limited by HTTP header value restrictions as OAuth token is frequently sent in HTTP header "Authorization".

    Valid chars for HTTP headers are specified by https://tools.ietf.org/html/rfc7230#section-3.2.6. Alternatively you may check HTTP header validating code of some popular HTTP client libs, for example see Headers.checkNameAndValue() util of OkHttp framework: https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/Headers.java

    And this is not all. I wouldn't include HTTP header separator (; and many others) and whitespace symbols (' ' and '\t') and double quote (") (see https://tools.ietf.org/html/rfc7230#section-3.2.6) as it would require to escape OAuth token before using in HTTP header. Frequently tokens are used by humans in curl test requests, and so good token generators don't add such characters. But you should check what characters may produce Oauth token generator with which your service is working before making any assumptions.

    0 讨论(0)
提交回复
热议问题