Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

oauth2.0 how to pass access token

People also ask

How is access token passed?

The application receives an access token after a user successfully authenticates and authorizes access, then passes the access token as a credential when it calls the target API.

What OAuth 2.0 token?

OAuth 2.0 is an authorization protocol and NOT an authentication protocol. As such, it is designed primarily as a means of granting access to a set of resources, for example, remote APIs or user's data. OAuth 2.0 uses Access Tokens.


With OAuth, the token is generally passed in the request headers. You may wish to try something similar to the following, for both POST or GET:

POST: curl http://api.localhost/write -H 'Authorization: Bearer ACCESS_TOKEN'

GET: curl http://api.localhost/read -H 'Authorization: Bearer ACCESS_TOKEN'

The value part of the Authorization key/value pair can vary by REST service provider. With Github, for instance, the header key/value pair looks like this:

curl -H "Authorization: token your_token" https://api.github.com/repos/user/repo

You may need to consult the webservice provider docs for details.