OAuth2 authentication in Yandex: obtaining access and refresh tokens

From Notes to self
Revision as of 17:42, 20 June 2021 by Verbovet (talk | contribs)
Jump to navigation Jump to search
  1. Application name
  2. Platforms > Web services > Callback URI. This can be any URI (we will use example.org)
  3. Scope

This will give us <ID> and <Password>.

Thus we obtained <ID>, <Password>, and <CODE>.

  • Run
curl -sS -X POST https://oauth.yandex.ru/token \
    -d grant_type=authorization_code \
    -d code=<CODE> \
    -d client_id=<ID> \
    -d client_secret=<Password>| jq .

This produces:

{
  "access_token": "<Access token>",
  "expires_in": xxxxxxxx,
  "refresh_token": "<Refresh token>",
  "token_type": "bearer"
}