{"_id":"58fd14f9809fc30f00f2ee08","__v":5,"category":{"_id":"58fd1460809fc30f00f2ee07","__v":0,"project":"55c8cff571d7580d0063a5e5","version":"57624356653c2d2200fec79c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-04-23T20:53:52.828Z","from_sync":false,"order":2,"slug":"oauth","title":"OAuth"},"user":"56f99ab84d2b4f3400edb636","parentDoc":null,"version":{"_id":"57624356653c2d2200fec79c","__v":21,"project":"55c8cff571d7580d0063a5e5","createdAt":"2016-06-16T06:12:38.244Z","releaseDate":"2016-06-16T06:12:38.244Z","categories":["57624356653c2d2200fec79d","57624356653c2d2200fec79e","57624356653c2d2200fec79f","57624356653c2d2200fec7a0","57624356653c2d2200fec7a1","57624356653c2d2200fec7a2","57624356653c2d2200fec7a3","57624356653c2d2200fec7a4","57624356653c2d2200fec7a5","57624356653c2d2200fec7a6","57624356653c2d2200fec7a7","57624356653c2d2200fec7a8","57624356653c2d2200fec7a9","57624356653c2d2200fec7aa","5779ca1b99b40b0e005abb3a","5779d198aea88b0e00f63277","5797d3ab17ced017003c4be4","57ac170ef1cdae0e0053cdfc","57dbfc723ed3450e00dc9e6d","5804d12d16161c0f0077df9b","5841064b652e5b0f0015a7c8","588b5e5f2966b2230009cbf9","58a68ebf3239fa0f00857619","58c23c8b4922930f0050ac91","58fd1460809fc30f00f2ee07","5934eaf5328680002d77de6a","594bf91601cfe6000f40f4c5","595c4ed696b447001ba0cf6d","596524495cee50001575f5be","5970d4f1313162004dd303b5","59780fac24dbd1001a1fa057","59a8cfd3ead78a002d63cafe","59e0323d93da1f001c9ec170","5b0c16f2be9fcb0003e28222"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"4.0.0","version":"4"},"project":"55c8cff571d7580d0063a5e5","updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-04-23T20:56:25.993Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n    CURLOPT_URL => \"https://api.phone.com/v4/oauth/authorization?client_id=XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&response_type=code&scope=account-owner%20extension-user&redirect_uri=http%3A%2F%2Flocalhost&state=ThisIsEchoData\",\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_ENCODING => \"\",\n    CURLOPT_MAXREDIRS => 10,\n    CURLOPT_TIMEOUT => 30,\n    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n    CURLOPT_CUSTOMREQUEST => \"GET\",\n    CURLOPT_HTTPHEADER => array(\n        \"cache-control: no-cache\",\n        \"content-type: application/json\",\n    ),\n));\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n    echo \"cURL Error #:\" . $err;\n} else {\n    echo $response;\n}\n","name":"Create Authorization Code","language":"php"},{"name":"Create Token","language":"php","code":"<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n    CURLOPT_URL => \"https://api.phone.com/v4/oauth/authorization?client_id=XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&response_type=token&scope=account-owner%20extension-user&redirect_uri=http%3A%2F%2Flocalhost\",\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_ENCODING => \"\",\n    CURLOPT_MAXREDIRS => 10,\n    CURLOPT_TIMEOUT => 30,\n    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n    CURLOPT_CUSTOMREQUEST => \"GET\",\n    CURLOPT_HTTPHEADER => array(\n        \"cache-control: no-cache\",\n        \"content-type: application/json\",\n    ),\n));\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n    echo \"cURL Error #:\" . $err;\n} else {\n    echo $response;\n}"}]},"method":"get","results":{"codes":[{"status":302,"language":"http","code":"\nhttp://localhost/?code=mRxUuwgl0Xgjg8fIjweikoJPb1aaMBU8bt706656~6&state=ThisIsEchoData\n","name":"Create Authorization Code"},{"status":302,"name":"Create Token","language":"http","code":"\nhttp://localhost/#token_type=Bearer&expires_in=3600&access_token=c1VhLHk76RM222APPQzhyYNUmJh89BZDyQ706656~6&state=\n"}]},"settings":"","auth":"required","params":[{"_id":"58fd1fbc6b29580f00d913b0","ref":"","in":"query","required":true,"desc":"Client ID","default":"","type":"string","name":"client_id"},{"_id":"58fd292a35c59f0f0028d996","ref":"","in":"query","required":true,"desc":"'token' for Implicit Grant; 'code' for Authorization Code Grant","default":"","type":"string","name":"response_type"},{"_id":"58fd298754decc0f00f6bcc8","ref":"","in":"query","required":true,"desc":"account-owner, extension-user and/or methods:ALL, separated by space (%20)","default":"","type":"string","name":"scope"},{"_id":"58fd2a4990b1420f00448d8f","ref":"","in":"query","required":true,"desc":"The [URL](doc:account-oauth-clients-redirect-uris) where the response data of this API is redirected to","default":"","type":"string","name":"redirect_uri"},{"_id":"5a1b5360421ec6001e1b0df7","ref":"","in":"query","required":false,"desc":"Echo data returned in the response","default":"","type":"string","name":"state"}],"url":"/oauth/authorization?client_id=:client_id&response_type=:response_type&scope=:scope&redirect_uri=:redirect_uri"},"isReference":false,"order":1,"body":"[block:api-header]\n{}\n[/block]\n\n[block:api-header]\n{}\n[/block]","excerpt":"Create Authorization Code or Access Token.\n\nThe /oauth/authorization API supports Authorization Grant and Implicit Grant.  In Authorization Grant, this API returns a code (response_type=code) for clients implemented in a browser using a scripting language such as JavaScript. Users may then use the code via the [Create Access Token API](doc:create-oauth-access-token) to create an access token.  \n\nThe Implicit Grant is a simplified authorization code flow.  In the implicit flow, instead of issuing the client an authorization code, the client is issued an access token (response_type=token) directly.\n\nSee [OAuth](doc:oauth) for more details on how to obtain client id and client secret to create authorization code access token at real time.","slug":"create-oauth-authorization","type":"endpoint","title":"Create Authorization"}

getCreate Authorization

Create Authorization Code or Access Token. The /oauth/authorization API supports Authorization Grant and Implicit Grant. In Authorization Grant, this API returns a code (response_type=code) for clients implemented in a browser using a scripting language such as JavaScript. Users may then use the code via the [Create Access Token API](doc:create-oauth-access-token) to create an access token. The Implicit Grant is a simplified authorization code flow. In the implicit flow, instead of issuing the client an authorization code, the client is issued an access token (response_type=token) directly. See [OAuth](doc:oauth) for more details on how to obtain client id and client secret to create authorization code access token at real time.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Query Params

client_id:
required
string
Client ID
response_type:
required
string
'token' for Implicit Grant; 'code' for Authorization Code Grant
scope:
required
string
account-owner, extension-user and/or methods:ALL, separated by space (%20)
redirect_uri:
required
string
The [URL](doc:account-oauth-clients-redirect-uris) where the response data of this API is redirected to
state:
string
Echo data returned in the response

Examples


Result Format


Documentation

[block:api-header] {} [/block] [block:api-header] {} [/block]

User Information

Try It Out

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