Why should you base64 encode the Authorization header?

后端 未结 4 640
轻奢々
轻奢々 2021-02-08 13:56

Twitter\'s API requires sending an Authorization header that is a base64 encoding of an API key concatenated with an API secret key. In Node, I use:

var base64 =         


        
4条回答
  •  情话喂你
    2021-02-08 14:44

    By default, message header field parameters in Hypertext Transfer Protocol (HTTP) messages cannot carry characters outside the ISO- 8859-1 character set.

    If user name and password contains incompatible charset than HTTP would not be able to carry those text. to prevent from this we encode user name and password with base64 to make sure we are sending HTTP compatible char over HTTP. for more information see this Basic_access_authentication

提交回复
热议问题