{"_id":"54355bcc35740020002a1b3b","__v":0,"project":"543469460ef9c00800164f0e","parentDoc":null,"version":{"_id":"54346a2a0ef9c00800164f28","forked_from":"543469460ef9c00800164f11","project":"543469460ef9c00800164f0e","__v":7,"createdAt":"2014-10-07T22:33:14.982Z","releaseDate":"2014-10-07T22:33:14.982Z","categories":["54346a2b0ef9c00800164f29","543473445b10711400c6c21a","543473500ef9c00800164fde","54347c625b10711400c6c301","5434918d0ef9c008001651ff","5434b72c008ec22200d86ae7","5435990c495d5d0800f3a510"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2.0"},"user":"543469060ef9c00800164f01","editedParams":true,"is_link":false,"category":{"_id":"5434918d0ef9c008001651ff","pages":["5435626c5ff8a51a006e4110","543553953513400800a14736","543555cc3513400800a14752","54355bcc35740020002a1b3b","5434928b0ef9c0080016520e","54347c8e5b10711400c6c30a","54346f750ef9c00800164fa0","543470f45b10711400c6c1e5","543477b70ef9c0080016505b","543478fb5b10711400c6c29f","54347d105b10711400c6c318","54347df00ef9c008001650d2","54347edf5b10711400c6c336","54357a175e1b2020004380dc","543483520ef9c0080016512a","543484820ef9c0080016513a","5434887e5b10711400c6c3cd","543488c05b10711400c6c3d2","54348ac85b10711400c6c401","5434959c0ef9c0080016522d","543497030ef9c00800165244","543498ae5b10711400c6c4f6","54349b7f0ef9c00800165293","54349c070ef9c00800165298","54349dbf0ef9c008001652ad","5434ab8e0ef9c00800165384","5434abbb0ef9c0080016538f","5434ac495b10711400c6c626","5434ada40ef9c008001653a8","5434af0a0ef9c008001653bc","5434af5f0ef9c008001653c8","5434b00a5b10711400c6c66b","5434b0d15b10711400c6c68c","5434b1ee0ef9c00800165406","5434b26d0ef9c0080016541c","5434b3560ef9c00800165427","5434b3b40ef9c0080016545a","5434b49f008ec22200d86ab9","5434b51f008ec22200d86aca","5434b5a80ef9c0080016546f","5434b5f4008ec22200d86ad8","5434b676008ec22200d86add","5434b6e6008ec22200d86ae5"],"version":"54346a2a0ef9c00800164f28","__v":30,"project":"543469460ef9c00800164f0e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-08T01:21:17.804Z","from_sync":false,"order":1,"slug":"rest-api","title":"REST API"},"editedParams2":true,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-08T15:44:12.149Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"name":"Success","code":"{\n  \"token_type\": \"Bearer\",\n  \"access_token\": \"abcdefg123456\",\n  \"expires_in\": \"2147483647\",\n  \"scope\": null,\n  \"user_id\": \"12345\"\n}","language":"json","status":200},{"code":"{\n  \"error\": \"invalid_request\",\n  \"error_description\": \"Invalid grant_type parameters or parameter missing\"\n}","language":"json","status":400,"name":"Invalid grant_type argument"},{"code":"{\n  \"error\": \"unsupported_grant_type\"\n}","language":"json","status":400,"name":"Unsupported grant type"},{"name":"Invalid client","code":"{\n  \"error\": \"invalid_client\"\n}","language":"json","status":400},{"status":400,"name":"Unauthorized client","code":"{\n  \"error\": \"unauthorized_client\"\n}","language":"json"},{"code":"{\n  \"error\": \"invalid_request\"\n}","language":"json","status":400,"name":"Invalid auth code request"},{"code":"{\n  \"error\": \"invalid_grant\"\n}","language":"json","name":"Invalid auth code grant","status":400},{"code":"{\n  \"error\": \"expired_token\"\n}","language":"json","name":"Expired auth code token","status":400}]},"settings":"","try":false,"basic_auth":false,"method":"post","auth":"never","params":[{"_id":"54355bcc35740020002a1b40","ref":"","in":"body","required":true,"desc":"The authorization type","default":"authorization_code","type":"string","name":"grant_type"},{"_id":"54355bcc35740020002a1b3f","ref":"","in":"body","required":true,"desc":"The application's client id","default":"","type":"int","name":"client_id"},{"_id":"54355bcc35740020002a1b3e","ref":"","in":"body","required":true,"desc":"The uri the user will be redirected to after authorization. Must begin with or match the URI used in the /authorize request","default":"","type":"string","name":"redirect_uri"},{"_id":"54355bcc35740020002a1b3d","ref":"","in":"body","required":true,"desc":"The application's client secret","default":"","type":"string","name":"client_secret"},{"_id":"54355bcc35740020002a1b3c","ref":"","in":"body","required":true,"desc":"The authorization code returned by the authorize endpoint during the redirect","default":"","type":"string","name":"code"}],"url":"/v2/oauth2/token"},"isReference":false,"order":3,"body":"Retrieve an authorization token for the specified authorization code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /api/v2/oauth2/token HTTP/1.1\\nHost: www.formstack.com\\n\\nclient_id=1234&redirect_uri=http%3A%2F%2Fwww.example.com&client_secret=abcdefg&code=123456&grant_type=authorization_code\",\n      \"language\": \"http\"\n    },\n    {\n      \"code\": \"curl -X POST -i -d \\\"client_id=1234&redirect_uri=http%3A%2F%2Fwww.example.com&client_secret=abcdefg&code=123456&grant_type=authorization_code\\\" https://www.formstack.com/api/v2/oauth2/token\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nTo request an OAuth2 token to use with the Formstack API explorer, visit [here](https://www.formstack.com/readme_auth.php).","excerpt":"Once a user has authorized the client application and they are redirected, the client application can use the token endpoint to get an access token. Access tokens are then used to access protected resources.","slug":"oauth2-token-post","type":"endpoint","title":"/oauth2/token"}

post/oauth2/token

Once a user has authorized the client application and they are redirected, the client application can use the token endpoint to get an access token. Access tokens are then used to access protected resources.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

grant_type:
required
stringauthorization_code
The authorization type
client_id:
required
integer
The application's client id
redirect_uri:
required
string
The uri the user will be redirected to after authorization. Must begin with or match the URI used in the /authorize request
client_secret:
required
string
The application's client secret
code:
required
string
The authorization code returned by the authorize endpoint during the redirect

Result Format


Documentation

Retrieve an authorization token for the specified authorization code [block:code] { "codes": [ { "code": "POST /api/v2/oauth2/token HTTP/1.1\nHost: www.formstack.com\n\nclient_id=1234&redirect_uri=http%3A%2F%2Fwww.example.com&client_secret=abcdefg&code=123456&grant_type=authorization_code", "language": "http" }, { "code": "curl -X POST -i -d \"client_id=1234&redirect_uri=http%3A%2F%2Fwww.example.com&client_secret=abcdefg&code=123456&grant_type=authorization_code\" https://www.formstack.com/api/v2/oauth2/token", "language": "shell" } ] } [/block] To request an OAuth2 token to use with the Formstack API explorer, visit [here](https://www.formstack.com/readme_auth.php).

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}