OAuth APIs
Sample calls through proxy endpoint using above settings.
Create access token
curl -v -d '{"id":1,"method":"oauth2.createAccessToken","params":{"service_
key":"m9f.....uw3","client":{"client_id":"yq7...qa6x","client_
secret":"A...a"},"token_data":{"grant_type":"implicit"},"uri":{"redirect_
uri":"https://some.com/cb"},"user_context":"testUser1455730448397"},"jsonrpc":"2.0"}' -H 'Host:
api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 310
>
* upload completely sent off: 310 out of 310 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 231
< Date: Tue, 30 Oct 2018 00:38:26 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"token_type":"bearer","return_type":"json","access_token":"unrct8wsweny8h3b3kw39wab","expires_in":36000,"scope":null,"user_
context":"testUser1455730448397","uri":null,"extended":null,"state":null}}
Create authorization code
curl -v -d '{ "id":1,"method":"oauth2.createAuthorizationCode","params":{"service_
key":"m9f.....uw3","client":{"client_id":"yq7...qa6x"},"response_
type":"code","uri":{"redirect_uri":"https://some.com/cb"},"user_context":
"testUser1455730448397"},"jsonrpc":"2.0"}' -H 'Host: api.mashery.com' -H 'Content-Type:
application/json' 'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 277
>
* upload completely sent off: 277 out of 277 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 168
< Date: Tue, 30 Oct 2018 00:42:12 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"code":"p2kjsmn8mw2xb3d2ksryxk6z","uri":{"redirect_
uri":"https://some.com/cb?code=p2kjsmn8mw2xb3d2ksryxk6z","state":""}},"error":null}
Create access token with authorization code
curl -v -d '{"id":1,"method":"oauth2.createAccessToken","params":{"service_
key":"m9f.....uw3","client":{"client_id":"yq7...qa6x","client_
secret":"A...a"},"token_data":{"grant_type":"authorization_
code","code":"p2kjsmn8mw2xb3d2ksryxk6z","scope":"scope1"},"uri":{"redirect_
uri":"https://some.com/cb"},"user_context": "testUser1455730448397"},"jsonrpc":"2.0"}' -H
'Content-Type: application/json' -H 'Host: api.mashery.com'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 372
>
* upload completely sent off: 372 out of 372 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 274
< Date: Tue, 30 Oct 2018 00:49:18 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"token_type":"bearer","return_type":"json","access_
token":"rjzb2k26cgv7tufe2j8cs7rm","expires_in":36000,"refresh_
token":"zgwyg64s2ejc6catffvg5kbx","scope":null,"user_
context":"testUser1455730448397","uri":null,"extended":null,"state":null}}
Update access token
curl -v -d '{"id":1,"method":"oauth2.updateAccessToken","params":{"service_
key":"m9f.....uw3","client":{"client_id":"yq7...qa6x","client_
secret":"A...a"}, "access_token":"rjzb2k26cgv7tufe2j8cs7rm","user_
context":"testUser1455730448397", "expires_in":600},"jsonrpc":"2.0"}' -H 'Host: api.mashery.com' -
H 'Content-Type: application/json' 'http://X.X.99.100:80/oauth/authorization/?api_
key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 287
>
* upload completely sent off: 287 out of 287 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 322
< Date: Tue, 30 Oct 2018 01:01:50 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"token_type":"bearer","access_
token":"rjzb2k26cgv7tufe2j8cs7rm","expires":"2018-10-30T11:01:50Z","refresh_token_expires":1540864158505,"scope":null,"user_context":"testUser1455730448397","uri":null,"grant_
type":"authorization_code","client_id":"yq7...qa6x","extended":null}
Fetch access token
curl -v -d '{"id": 1,"jsonrpc":"2.0","method": "oauth2.fetchAccessToken","params": {"service_
key":"m9f.....uw3","access_token": "rjzb2k26cgv7tufe2j8cs7rm"}}' -H 'Host:
api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 157
>
* upload completely sent off: 157 out of 157 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 242
< Date: Tue, 30 Oct 2018 01:05:25 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"token_type":"bearer","expires":"2018-10-
30T11:01:50Z","scope":null,"user_context":"testUser1455730448397","uri":null,"grant_
type":"authorization_code","client_id":"yq7...qa6x","extended":null}}
Fetch application
curl -v -d '{"id": 1,"jsonrpc":"2.0","method":"oauth2.fetchApplication","params":{"service_
key":"m9f.....uw3","client":{"client_id":"yq7...qa6x","client_
secret":"A...a"}}}' -H 'Host: api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 187
>
* upload completely sent off: 187 out of 187 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 82
< Date: Tue, 30 Oct 2018 01:10:58 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"id":251547,"name":"TestOAuthRegisterCallBack"}}
Fetch user application
curl -v -d '{ "id":1, "method":"oauth2.fetchUserApplications", "params":{ "service_
key":"m9f.....uw3", "user_context":"testUser1455730448397" },"jsonrpc":"2.0"}' -H
'Host: api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 162
>
* upload completely sent off: 162 out of 162 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 195
< Date: Tue, 30 Oct 2018 01:12:32 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":[{"id":251547,"name":"TestOAuthRegisterCallBack","access_tokens":
["rjzb2k26cgv7tufe2j8cs7rm","unrct8wsweny8h3b3kw39wab"],"client_
id":"yq7...qa6x"}]}
Revoke access token
curl -v -d '{ "id":1, "method":"oauth2.revokeAccessToken", "params":{ "service_
key":"m9f.....uw3", "client": { "client_id":"yq7...qa6x", "client_
secret":"A...a" }, "access_token":"rjzb2k26cgv7tufe2j8cs7rm" },"jsonrpc":"2.0"}' -H 'Host:api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 240
>
* upload completely sent off: 240 out of 240 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 38
< Date: Tue, 30 Oct 2018 01:17:10 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":true}
Revoke user application
curl -v -d '{ "id":1, "method":"oauth2.revokeUserApplication", "params":{ "service_
key":"m9f.....uw3", "client": { "client_id":"yq7...qa6x", "client_
secret":"A...a" }, "user_context":"testUser1455730448397" },"jsonrpc":"2.0"}' -H 'Host:
api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 241
>
* upload completely sent off: 241 out of 241 bytes
< HTTP/1.1 500 Server Error
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 81
< Date: Tue, 30 Oct 2018 16:41:56 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"error":{"message":"Internal Server Error","code":-2001}}
Refresh token
curl -k -v -d '{"id":1,"method":"oauth2.createAccessToken","params":{"service_
key":"m9f.....uw3","client":{"client_id":"yq7...qa6x","client_
secret":"A...a"},"token_data":{"grant_type":"refresh_token","refresh_
token":"8f9...p2jh"},"uri":{"redirect_uri":"https://some.com/cb"},"user_
context":null},"jsonrpc":"2.0"}' -H 'Host: api.mashery.com' -H 'Content-Type: application/json'
'http://X.X.99.100:80/oauth/authorization/?api_key=8qav...dg3'
* Trying X.X.99.100...
* Connected to X.X.99.100 (X.X.99.100) port 80 (#0)
> POST /oauth/auth/v2/?api_key=8qav...dg3 HTTP/1.1
> Host: api.mashery.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 339
>
* upload completely sent off: 339 out of 339 bytes
< HTTP/1.1 200 OK
< X-Mashery-Responder: 8abfe284898c
< Content-Type: application/json;charset=UTF-8
< Cache-Control: no-store
< Content-Length: 274
< Date: Tue, 30 Oct 2018 16:55:36 GMT
<
* Connection #0 to host X.X.99.100 left intact
{"jsonrpc":"2.0","id":1,"result":{"token_type":"bearer","return_type":"json","access_
token":"79rkkkxd4rk2zzbrqj4z93vb","expires_in":36000,"refresh_
token":"7db67za3xvdg99nc7gnctkqw","scope":null,"user_
context":"testUser1455730448397","uri":null,"extended":null,"state":null}}