M
M
Matvey Pravosudov2014-01-01 16:47:13
PHP
Matvey Pravosudov, 2014-01-01 16:47:13

How to get access_token in Dropbox?

I'm trying to use the Dropbox OAuth API, I get only the auth_token, but it's not clear how to convert it to an access_token for a permanent connection (without curl).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2014-01-02
@oxyberg

Judging by the documentation, something like this (if without cURL):

$context = stream_context_create(array('http' => array(
    'method'  => 'POST',
    'header'  => "Content-Type: application/x-www-form-urlencoded\r\n".
      "Authorization: Basic ".base64_encode("<app key>:<app secret>")."\r\n",
    'content' => http_build_query(array(
    	'code' => <authorization code>,
    	'grant_type' => 'authorization_code',
    	'redirect_uri' => <redirect URI>,
    )),
  )));
                       
$url = 'https://api.dropbox.com/1/oauth2/token';
$result = file_get_contents($url, false, $context);
$result_json = json_decode($result);

echo $result_json->access_token;

They have a well-written SDK , take it and use it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question