Authorization¶
The preferred way to authorize is an async with
statement.
After authorization the session will have the following attributes:
access_token
akasession_key
, alwayssession_secret_key
if Implicit Grant / Password Grant usedpermission_granted
if Implicit Grant usedstate
if Implicit Grant usedtoken_type
if Code Grant / Refresh Token Grant usedrefresh_token
if Code Grant usedexpires_in
if Code Grant / Implicit Grant / Refresh Token Grant used
Authorization Code Grant¶
from aiookru import CodeSession, API
app_id = 123456
app_key = 'abcde'
app_secret_key = 'xyz'
async with CodeSession(app_id, app_key, app_secret_key, code, redirect_uri) as session:
api = API(session)
...
About OAuth 2.0 Authorization Code Grant: https://oauth.net/2/grant-types/authorization-code/
For more details, see https://apiok.ru/ext/oauth/server
Implicit Grant¶
from aiookru import ImplicitSession, API
app_id = 123456
app_key = 'abcde'
app_secret_key = ''
async with ImplicitSession(app_id, app_key, app_secret_key, login, passwd, scope) as session:
api = API(session)
...
About OAuth 2.0 Implicit Grant: https://oauth.net/2/grant-types/implicit/
For more details, see https://apiok.ru/ext/oauth/client
Password Grant¶
from aiookru import PasswordSession, API
app_id = 123456
app_key = 'abcde'
app_secret_key = ''
async with PasswordSession(app_id, app_key, app_secret_key, login, passwd) as session:
api = API(session)
...
About OAuth 2.0 Password Grant: https://oauth.net/2/grant-types/password/
Refresh Token¶
from aiookru import RefreshSession, API
app_id = 123456
app_key = 'abcde'
app_secret_key = 'xyz'
async with RefreshSession(app_id, app_key, app_secret_key, refresh_token) as session:
api = API(session)
...
About OAuth 2.0 Refresh Token: https://oauth.net/2/grant-types/refresh-token/
For more details, see https://apiok.ru/ext/oauth/server