Table of Contents |
---|
When & How to Use Vendor Services
...
Example REST request
Headers
- X-Application' : 'your app key'
- 'X-Authentication' : 'your session token'
- Accept: application/json
- Content-Type: application/json
Endpoint
Code Block | ||
---|---|---|
| ||
https://api.betfair.com/exchange/account/rest/v1.0/token/ |
Request
Code Block | ||
---|---|---|
| ||
{"client_id |
client_secret=VENDOR_SECRET
"="4534","grant_type |
":"AUTHORIZATION_CODE |
code=THE_AUTH_CODE
Example Response
","code":"-22a1-12151008-000007cb61","client_secret":"bc183d-f5-40dc-82a6-d97681"} |
Response
Code Block | ||
---|---|---|
| ||
{"access_token":"KeOi+kyg2RvDK4HM+W46CvSnP5w=","refresh_token":"50d76117-7f85-375v-a38f-ffb332713f93","application_subscription":{"vendor_client_id":"456238"},"token_type":"BEARER","expires_in":"14400"} |
Example Token request - Json-RPC
Headers
Code Block | ||
---|---|---|
| ||
X-Application' : 'your |
App key' |
X-Authentication' : 'your session token' Accept:application/json |
Endpoint
Code Block | ||
---|---|---|
| ||
https://api.betfair.com/exchange/account/json-rpc/v1 |
Request
Code Block | ||
---|---|---|
| ||
{"jsonrpc": "2.0", |
"method": "AccountAPING/v1.0/token", |
"params": {"client_id":"CLIENTID","grant_type":"AUTHORIZATION_CODE","code":"CODE","client_secret":"CLIENTSECRET"}, |
"id": 1 } |
}
OAuth 2 Flow - Using the Refresh Token
...
- Header: 'X-Application' : 'your app key'
- Header: 'X-Authentication' : 'your session token'
- client_id: your vendor ID, obtained from /wiki/spaces/OL/pages/1671181
- grant_type: 'REFRESH_TOKEN'
- refresh_token: the refresh token for the user
- client_secret: your secret, obtained from GetDeveloperAppKeys/wiki/spaces/OL/pages/1671181
This will return the same information as the original call:
...
Example request using REST
...
Example response
{ "access_token" : "KeOi+kyg2RvDK4HM+W46CvSnP5w=" , "refresh_token" : "50d76117-7f85-375v-a38f-ffb332713f93" , "application_subscription" :{ "vendor_client_id" : "456238" }, "token_type" : "BEARER" , "expires_in" : "14400" } |
You can user the 'expires_in' value to determine when the access token will stop being valid. Alternatively, if calls made with the access token start returning an INVALID_SESSION error, it is likely that the token has expired.
...