Token Generation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2015 03:13 AM
I am trying to generate the access token for an application which I have deployed over serviceNow,
Referred the link: http://wiki.servicenow.com/index.php?title=REST_API
Rest API : https://<InstanceName>.service-now.com/oauth_token.do
Request Body:
{"grant_type":"password","client_id":"33eb1705c75f3154400b1237989343b5","client_secret":4gE[IT#5qk,
"username":"UserName",
"password":"Password"}
Response:
Status Code: 401 Unauthorized
{
"error": "server_error",
"error_description": "access_denied"
}
Am I missing anything?
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2016 09:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2016 09:23 AM
Thanks. Can you double-check that the values in the form-encoded body are actually form-encoded? In other words, if the username is "someuser@domain.com", then the username needs to be specified as:
&username=someuser%40domain.com
This goes for all the fields in body if they contain special characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2016 09:52 AM
I have tried encoding all the fields and the same results. Also for the username I have tried myusername, domain\myusername, and myusername@domain.com but still no success.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2016 09:53 AM
Here is a request that works for me using cURL. Note that my client secret is my##secret, and my user's password is CompleX$$pw, so see encoding.
$ curl "https://instance.service-now.com/oauth_token.do" -v -XPOST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: */*" --data "grant_type=password&client_id=8c2dd30e1778120027b33a5ca050ded8&client_secret=my%23%23secret&username=test.user&password=CompleX%24%24pw"
> POST /oauth_token.do HTTP/1.1
> User-Agent: curl/7.30.0
> Host: instance.service-now.com
> Content-Type: application/x-www-form-urlencoded
> Accept: */*
> Content-Length: 129
< HTTP/1.1 200 OK
< Set-Cookie: JSESSIONID=1C99CC9C75A4B5FE9AA49063F62015DD;Secure; Path=/; HttpOnly
< Set-Cookie: glide_user_route=glide.70655daa9db576ebb930d23f08ff00af;secure; Expires=Wed, 26-Jan-2084 21:01:14 GMT; Path=/; HttpOnly
< Set-Cookie: glide_session_store=8F6ED34E4F7812001F6EAC118110C740; Expires=Fri, 08-Jan-2016 18:17:07 GMT; Path=/; HttpOnly
< Content-Type: application/json;charset=utf-8
< Content-Length: 272
< Date: Fri, 08 Jan 2016 17:47:07 GMT
< Server: ServiceNow
< Set-Cookie: BIGipServerpool_instance=981534218.36158.0000; path=/
{
"expires_in": 1799,
"token_type": "Bearer",
"scope": "useraccount",
"refresh_token": "mk0ywn5FnoDComsmC62xbHruusboDr7SlyL1YfzNiygKG2IrfXq9QpzCjQBlE18D3vpjPivepITsnlayTgv0PQ",
"access_token": "S05_5dP0W9SA0i2bydW5DG3jJtlZdwpXrsO9Zf6KDkdzZhML0PhmHWBtU4ajsL8Z6XZmHO9aoxbRB5rWyY2A5Q"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2016 10:12 AM
I am not familiar with curl so how do I use this? Is this a program that I need to install on my computer?