- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 12:31 AM
Hi,
i follow the article OAuth authorization code grant flow to get tokens
initially i made request
https://xxxx.service-now.com/oauth_auth.do?response_type=code&client_id=****534e4e81b7f
and the response after allowing access to
https://<callback-url>?code=Z2YYGhgfh1tMoFPDO7Dr0nZuPnhQPs53qwkm_Sw99gpUf92gU3x_OOuoOqdYBvlPFF01pOfgZg9VoXpCruSRYQ
after that to get token
https://xxxx.service-now.com/oauth_token.do?grant_type=authorization_code&code=<***>&client_id=<***>&client_secret=<***>
when i did request this,throwing error
{"error_description": "access_denied","error": "server_error"}
can't i get access_token and refresh_token in json format?
help me
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 04:06 AM
Finally we did it. Here is working solution written in python.
1. Initial request (URL where to redirect user) -
2. Request to get access/refresh tokens by code.
import base64 |
import requests |
post_data = { |
'grant_type': 'authorization_code', |
'code': '<code>', |
'redirect_uri': '<your-redirect-url>', |
'scope': 'useraccount' |
} |
auth = base64.b64encode('<client_id>:<client_secret>') |
headers = { |
'Authorization': 'Basic {}'.format(auth) |
} |
resp = requests.post( |
'https://<your_instance>.service-now.com/oauth_token.do', |
data=post_data, |
headers=headers) |
# Now response contains access and refresh tokens. |
print(resp.json()) |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 04:06 AM
Finally we did it. Here is working solution written in python.
1. Initial request (URL where to redirect user) -
2. Request to get access/refresh tokens by code.
import base64 |
import requests |
post_data = { |
'grant_type': 'authorization_code', |
'code': '<code>', |
'redirect_uri': '<your-redirect-url>', |
'scope': 'useraccount' |
} |
auth = base64.b64encode('<client_id>:<client_secret>') |
headers = { |
'Authorization': 'Basic {}'.format(auth) |
} |
resp = requests.post( |
'https://<your_instance>.service-now.com/oauth_token.do', |
data=post_data, |
headers=headers) |
# Now response contains access and refresh tokens. |
print(resp.json()) |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 03:22 AM
thnx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2018 05:19 AM
Hello Team,
how do we call the redirect_uri when no redirect url register under application registry?