How to configure HTTP authorization header using Javascript

I use oauth in the API library, and the API requires that the authorization header be explicitly set for each request.

I am familiar with the setRequestHeader method, using it like:

this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

However, I'm not sure how to properly configure the authorization header, since it has so many parameters. An example of what the title should look like:

Authorization: OAuth realm="",oauth_version="1.0",oauth_consumer_key="consumer",oauth_token="foo",oauth_timestamp="timestamp",oauth_nonce="ononce",oauth_signature_method="PLAINTEXT",oauth_signature="osig"

How to properly configure the authorization header in this format using setRequestHeader? Thank!

+3
source share
1 answer

Use the OAuth JavaScript library. It configures to build OAuth signed headers for you ...

http://oauth.googlecode.com/svn/code/javascript/

+2

Source: https://habr.com/ru/post/1773154/


All Articles