{"_id":"56b65af6e8b41d17005fc332","category":{"_id":"56b657e11bc6970d009feee7","project":"56acd71213ac890d001c3c7a","__v":2,"pages":["56b65931c4bc261700d946a4","56b65af6e8b41d17005fc332"],"version":"56acd71213ac890d001c3c7d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-06T20:30:25.089Z","from_sync":false,"order":3,"slug":"oauth-resource","title":"OAuth Resource"},"project":"56acd71213ac890d001c3c7a","editedParams":true,"githubsync":"","parentDoc":null,"user":"56acd6caa040860d00ac94a2","editedParams2":true,"__v":1,"version":{"_id":"56acd71213ac890d001c3c7d","project":"56acd71213ac890d001c3c7a","__v":15,"createdAt":"2016-01-30T15:30:26.928Z","releaseDate":"2016-01-30T15:30:26.928Z","categories":["56acd71313ac890d001c3c7e","56acd8f113ac890d001c3c81","56acd8f95ac4060d0027865e","56acd93a13ac890d001c3c82","56ad20660ab3c00d00ce3347","56ad356a2a7860170013f714","56ad47eb0ab3c00d00ce334f","56afd523bc304a0d00ace1df","56b29a019621f20d00efb37e","56b657e11bc6970d009feee7","5845cc3c39950c1b002afe77","5845cde163c11b250037967e","5846efd45d064323007b17b4","588604da4674e32300efd160","588627882393d50f00f1322c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-06T20:43:34.565Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"$response = $guzzleClient->post('https://api.gamewisp.com/pub/v1/oauth/token', [\n       'form_params' => [\n         'grant_type'    => 'authorization_code',\n         'client_id'     => 'your client ID',\n         'client_secret' => 'your client secret',\n         'redirect_uri'  => 'your redirect uri',\n         'code'          => $code\n       ]\n     ]);\n\n$result = json_decode($response->getBody());","language":"php"},{"code":"//The following example uses NodeJS with Express and the simple-oauth2 packages.\n\nvar app = require('express')();\nvar oauth2 = require('simple-oauth2')(oAuthInfo);\n\napp.get('your-redirect-uri', function(req, res){\n\tvar token = oauth2.authCode.getToken({\n    code: code,\n    redirect_uri: 'your-redirect-uri'\n  }).then(function saveToken(result){\n    token = oauth2.accessToken.create(result);\n    accessToken = token.token.data.access_token;\n    //store and use the token...\n\n  }).catch( function logError(error){\n    //your error catching here.\n});","language":"javascript"}]},"method":"post","results":{"codes":[{"language":"json","status":200,"name":"","code":"   \n{ \n  access_token: 'the-access-token',\n  token_type: 'Bearer',\n  expires_in: 3600,\n  refresh_token: 'the-refresh-token' ,\n  expires_at: '2016-02-15 12:05:00' \n }"}]},"settings":"","auth":"required","params":[{"_id":"56b65c8b3760681700638548","ref":"","in":"body","required":true,"desc":"The grant type of this request. Will be authorization_code or refresh_token depending on which is accompanying this request","default":"","type":"string","name":"grant_type"},{"_id":"56b65c8b3760681700638547","ref":"","in":"body","required":true,"desc":"Your application's client_id","default":"","type":"string","name":"client_id"},{"_id":"56b65c8b3760681700638546","ref":"","in":"body","required":true,"desc":"Your application's client_secret","default":"","type":"string","name":"client_secret"},{"_id":"56b65c8b3760681700638545","ref":"","in":"body","required":true,"desc":"Your application's redirect_uri","default":"","type":"string","name":"redirect_uri"},{"_id":"56b65c8b3760681700638544","ref":"","in":"body","required":true,"desc":"The code obtained from the /oauth/authorize endpoint. Not required when using the refresh_token grant","default":"","type":"string","name":"code"},{"_id":"56b65c8b3760681700638543","ref":"","in":"body","required":false,"desc":"The refresh_token received from a previous /token response. Required if grant_type is refresh_token","default":"","type":"string","name":"refresh_token"}],"url":"/oauth/token"},"isReference":false,"order":1,"body":"[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"The Response on this endpoint has changed\",\n  \"body\": \"If you have legacy API code, note that this response has changed. You will need to update your code accordingly. \\n\\nThe access_code field is no longer nested inside a data object in the response and is instead in the root of the response. This is more in accordance with examples provided in the OAuth2 specification.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Need more Help?\",\n  \"body\": \"For a thorough walkthrough of how to use this endpoint, check out [Connecting to a GameWisp Channel](https://gamewisp.readme.io/docs/connecting-to-a-gamewisp-channel)\"\n}\n[/block]","excerpt":"After successful redirect from /user/authorize use this endpoint to exchange a code for an access_token","slug":"oauthtoken","type":"endpoint","title":"/oauth/token"}

post/oauth/token

After successful redirect from /user/authorize use this endpoint to exchange a code for an access_token

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

grant_type:
required
string
The grant type of this request. Will be authorization_code or refresh_token depending on which is accompanying this request
client_id:
required
string
Your application's client_id
client_secret:
required
string
Your application's client_secret
redirect_uri:
required
string
Your application's redirect_uri
code:
required
string
The code obtained from the /oauth/authorize endpoint. Not required when using the refresh_token grant
refresh_token:
string
The refresh_token received from a previous /token response. Required if grant_type is refresh_token

Examples


Result Format


Documentation

[block:callout] { "type": "danger", "title": "The Response on this endpoint has changed", "body": "If you have legacy API code, note that this response has changed. You will need to update your code accordingly. \n\nThe access_code field is no longer nested inside a data object in the response and is instead in the root of the response. This is more in accordance with examples provided in the OAuth2 specification." } [/block] [block:callout] { "type": "info", "title": "Need more Help?", "body": "For a thorough walkthrough of how to use this endpoint, check out [Connecting to a GameWisp Channel](https://gamewisp.readme.io/docs/connecting-to-a-gamewisp-channel)" } [/block]