Closed macdev14 closed 2 years ago
hey @macdev14 thanks for your message! could you provide more details about the issue in order to reproduce it (e.g. code snippets)?
bx24 = Bitrix24('xxxx.bitrix24.com.br', 'client_id', 'secret_key' )
print(bx24.build_authorization_url())
print(bx24.obtain_tokens('AnAuthorizationCode'))
returns {'error': 'invalid_grant', 'domain': 'xxxx.bitrix24.com.br'}
As I've seen it should get the code from the url code=xxxxx
then send a GET request like this to get the access token:
https://xxxx.bitrix24.com.br/oauth/token/?grant_type=authorization_code&client_id=EXAMPLE&client_secret=SECRET_EXAMPLE&code=CODE_FROM_AUTHORIZATION_URL
returns the following:
{ "access_token": "XXXXXXXX", "expires": 1649707401, "expires_in": 3600, "scope": "app", "domain": "xxxx.bitrix24.com.br", "server_endpoint": "https:\/\/oauth.bitrix.info\/rest\/", "status": "L", "client_endpoint": "https:\/\/xxxx.bitrix24.com.br\/rest\/", "member_id": "xxxxx", "user_id": 000, "refresh_token": "xxxxxxxxx" }
I didn't set the code=00000
value in bx24.obtain_tokens('AnAuthorizationCode')) , that's why, thank you!
Getting {'error': 'invalid_grant', 'domain': 'xxxx.bitrix24.com.br'}
redirects to the following URL when authorization URL is opened
http://localhost:8000/?code=_xxxxx_&state=&domain=xxxx.bitrix24.com.br&member_id=0_example_0&scope=crm&server_domain=oauth.bitrix.info