How to get access_token with cozy-stack


#1

Hi, I want to get access_token using POST /auth/access_token.
client_id, client_secret, code are required.
What requests can I get in order after GET /auth/login?

Please let me know if you know anyone.


#2

Hello @moriokatky,

Here’s a sample script that call the API (using curl) to get a token allowing to access to data inside a Cozy: https://gist.github.com/clochix/3f03ae72ff3e249cf804a4f01fe81d0d#file-cozyexport-sh-L18

You have to call /auth/register to get a client_id and a client_secret, then send this tokens to /auth/authorize.
You will get an URL. Opening this URL, your server will ask to authorize your application to access the data. If you agree, your Cozy server will call the URL provided by the application to send it a code. So your application should probably listen on some port on localhost to get the code.

Call /auth/access_token with this code to get the real access_token.

Hope it may help.


#3

Thank you for explaining.
The introduced source is very easy to understand…


#4

This post was flagged by the community and is temporarily hidden.