<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OAuth2 access token request - Basic authentication not working in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259178#M15061</link>
    <description>&lt;P&gt;I am trying to integrate Dropbox in my webservice. However I decided to use a direct integration instead of any APIs as I need a limited number of functions only and not used to code object orientated in PHP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For any reason my authentication token handling is not working. I figured out, something is wrong with the basic authentifiation, as some other functions which should work with basic as well as bearer authentification do only work with the last one mentioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;function dropboxAuthentication($code){

    global $authToken;&lt;BR /&gt;    $parameters['code']=$code;&lt;BR /&gt;    $parameters['grant_type']="authorization_code";
    $parameters['redirect_uri']="https://myurl.com/file.php";

    // Create the context for the request
    $context = stream_context_create(array(
        'http' =&amp;gt; array(
            'method' =&amp;gt; 'POST',
            'header' =&amp;gt; 'Authorization: {Basic '.base64_encode("my app id:my app secret").'}\r\n'.
                'Content-Type: application/json\r\n',
            'content' =&amp;gt; json_encode($parameters)
       )
    ));

    // Send the request
    $response = file_get_contents('https://api.dropboxapi.com/oauth2/token', FALSE, $context);

    // Check for errors
    if($response === FALSE){
        die('Error');
    }

    // Decode the response
    $result=json_decode($response, TRUE);
    return $result['code'];

}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The file accessed after the login calls the function with the temporary code given. The temporary code is received well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result (response body) is always&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Error&lt;/PRE&gt;
&lt;P&gt;I checked the response code which is a HTTP Error 400.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the HTTP response headers attached&lt;/P&gt;
&lt;LI-SPOILER&gt;&lt;SPAN&gt;HTTP/1.1 400 Bad RequestServer: nginxDate: Fri, 05 Jan 2018 21:15:28 GMTContent-Type: application/jsonConnection: closeX-Dropbox-Request-Id: 7b42fa04f93fd7493deb1c7a34847cdeX-Frame-Options: DENYContent-Security-Policy: sandbox; frame-ancestors 'none'X-Content-Type-Options: nosniffContent-Disposition: attachment; filename='error'&lt;/SPAN&gt;&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your support!&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:16:19 GMT</pubDate>
    <dc:creator>pineapps</dc:creator>
    <dc:date>2019-05-29T09:16:19Z</dc:date>
    <item>
      <title>OAuth2 access token request - Basic authentication not working</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259178#M15061</link>
      <description>&lt;P&gt;I am trying to integrate Dropbox in my webservice. However I decided to use a direct integration instead of any APIs as I need a limited number of functions only and not used to code object orientated in PHP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For any reason my authentication token handling is not working. I figured out, something is wrong with the basic authentifiation, as some other functions which should work with basic as well as bearer authentification do only work with the last one mentioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;function dropboxAuthentication($code){

    global $authToken;&lt;BR /&gt;    $parameters['code']=$code;&lt;BR /&gt;    $parameters['grant_type']="authorization_code";
    $parameters['redirect_uri']="https://myurl.com/file.php";

    // Create the context for the request
    $context = stream_context_create(array(
        'http' =&amp;gt; array(
            'method' =&amp;gt; 'POST',
            'header' =&amp;gt; 'Authorization: {Basic '.base64_encode("my app id:my app secret").'}\r\n'.
                'Content-Type: application/json\r\n',
            'content' =&amp;gt; json_encode($parameters)
       )
    ));

    // Send the request
    $response = file_get_contents('https://api.dropboxapi.com/oauth2/token', FALSE, $context);

    // Check for errors
    if($response === FALSE){
        die('Error');
    }

    // Decode the response
    $result=json_decode($response, TRUE);
    return $result['code'];

}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The file accessed after the login calls the function with the temporary code given. The temporary code is received well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result (response body) is always&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Error&lt;/PRE&gt;
&lt;P&gt;I checked the response code which is a HTTP Error 400.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the HTTP response headers attached&lt;/P&gt;
&lt;LI-SPOILER&gt;&lt;SPAN&gt;HTTP/1.1 400 Bad RequestServer: nginxDate: Fri, 05 Jan 2018 21:15:28 GMTContent-Type: application/jsonConnection: closeX-Dropbox-Request-Id: 7b42fa04f93fd7493deb1c7a34847cdeX-Frame-Options: DENYContent-Security-Policy: sandbox; frame-ancestors 'none'X-Content-Type-Options: nosniffContent-Disposition: attachment; filename='error'&lt;/SPAN&gt;&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your support!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:16:19 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259178#M15061</guid>
      <dc:creator>pineapps</dc:creator>
      <dc:date>2019-05-29T09:16:19Z</dc:date>
    </item>
    <item>
      <title>Betreff: OAuth2 access token request - Basic authentication not working</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259180#M15062</link>
      <description>&lt;P&gt;I managed to get additional information from the HTTP request:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;{"url":"https:\/\/api.dropboxapi.com\/oauth2\/token","content_type":"application\/json","http_code":400,"header_size":385,"request_size":350,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.287188,"namelookup_time":0.004172,"connect_time":0.018384,"pretransfer_time":0.053378,"size_upload":23,"size_download":97,"speed_download":337,"speed_upload":80,"download_content_length":-1,"upload_content_length":23,"starttransfer_time":0.287049,"redirect_time":0,"redirect_url":"","primary_ip":"162.125.66.7","certinfo":[],"primary_port":443,"local_ip":"85.13.153.199","local_port":45981}&lt;/PRE&gt;

Last data received
&lt;PRE&gt;:{"error_description": "No auth function available for given request", "error": "invalid_request"}&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:29:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259180#M15062</guid>
      <dc:creator>pineapps</dc:creator>
      <dc:date>2018-01-05T21:29:02Z</dc:date>
    </item>
    <item>
      <title>Betreff: OAuth2 access token request - Basic authentication not working</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259181#M15063</link>
      <description>It looks like this is a duplicate, so I'm closing this in favor of:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.dropboxforum.com/t5/API-support/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259164#M15054" target="_blank"&gt;https://www.dropboxforum.com/t5/API-support/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259164#M15054&lt;/A&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:35:56 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/OAuth2-access-token-request-Basic-authentication-not-working/m-p/259181#M15063</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-01-05T21:35:56Z</dc:date>
    </item>
  </channel>
</rss>

