OAuth2 authentication in Yandex: obtaining access and refresh tokens

From Notes to self
Revision as of 17:28, 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 .

  • 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 gives:

{
  "access_token": "AQAAAAAABtwbAAcxxvjAw4T1lEsdo2LeAubQ6vs",
  "expires_in": 31530461,
  "refresh_token": "1:SFiVi4AYNrcGyFiD:a8AkmmWDkZHfPQLUVkC888i6hctYhBQkTjZcNo3zeJOUyLckJ8Wq:4Jjw2oLglZp3H18lx75BIQ",
  "token_type": "bearer"
}