<?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/token route is returning a binary in response in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/715523#M31683</link>
    <description>&lt;P&gt;Hi, i'm having problems when deploying my integration to my QA environment, i have already tested it in development and everything was right but i'm getting a totally different response in the route /oauth2/token then what i was receiving during my tests.&lt;BR /&gt;The app environments are the same and the code too, so i'm lost over here, any answer could come handy!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here is how i start my OAUTH flow:&lt;BR /&gt;The client will call this route witch should redirect the client to Dropbox authorization page:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    async get(req, res) {
        const usuario = await Usuario.findByPk(req.params.usuario_id);

        return res.redirect(
            `https://www.dropbox.com/oauth2/authorize?client_id=${process.env['APP_KEY']}&amp;amp;response_type=code&amp;amp;redirect_uri=${process.env.DROPBOX_WEBHOOK_URL}&amp;amp;token_access_type=offline&amp;amp;state=unidade_id:${usuario.unidade_id}`
        );
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the user authorizing my app the code bellow is called witch is the code for the route provided in the redirect_uri query param:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    async index(req, res) {
        const params = new URLSearchParams();
        params.append('code', req.query.code);
        params.append('client_id', process.env['APP_KEY']);
        params.append('client_secret', process.env['APP_SECRET']);
        params.append('grant_type', 'authorization_code');

        params.append('redirect_uri', process.env.DROPBOX_WEBHOOK_URL);

        const fronURLRedirect = new URL(
            '/dropbox',
            process.env['APP_FRONT_URL']
        );
        try {
            const { data } = await axios.post(
                process.env['DROPBOX_OAUTH2_TOKEN_ROUTE'],
                params
            );

            const [_, unidade_id] = req.query.state.split(':');

            await AcessoDropbox.create({
                ...data,
                update_token_date: new Date(),
                unidade_id,
            });

            fronURLRedirect.pathname = '/dropbox/sucesso';
            return res.redirect(fronURLRedirect.href);
        } catch (error) {
            console.log(error);

            fronURLRedirect.pathname = '/dropbox/erro';
            return res.redirect(fronURLRedirect.href);
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And after that our app is successfully authorized, at least during development, here is the return value that i receive from my POST call in the code above in development:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_0-1695329213423.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40700iD4DFAC173B4D1ACD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_0-1695329213423.png" alt="us0p_0-1695329213423.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And here is an example of what i receive back in QA with the same code, same app key and secret, the only difference is the redirect_uri:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_2-1695329318871.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40702i45A00F77F135B861/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_2-1695329318871.png" alt="us0p_2-1695329318871.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Here is a full print of my debugging:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_5-1695329485595.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40705iD821BE980C9ECA42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_5-1695329485595.png" alt="us0p_5-1695329485595.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm also receiving the query params as it should:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_3-1695329405356.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40703i7CACEF2C53223D85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_3-1695329405356.png" alt="us0p_3-1695329405356.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It looks like i'm receiving a binary as a response witch is totally different from what i was receiving during my tests, i searched the docs and did some googling but no luck!&lt;/P&gt;
&lt;P&gt;My Dropbox app isn't applied to production, i'm wondering if that's the problem.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2023 21:39:38 GMT</pubDate>
    <dc:creator>us0p</dc:creator>
    <dc:date>2023-09-21T21:39:38Z</dc:date>
    <item>
      <title>/oauth2/token route is returning a binary in response</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/715523#M31683</link>
      <description>&lt;P&gt;Hi, i'm having problems when deploying my integration to my QA environment, i have already tested it in development and everything was right but i'm getting a totally different response in the route /oauth2/token then what i was receiving during my tests.&lt;BR /&gt;The app environments are the same and the code too, so i'm lost over here, any answer could come handy!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here is how i start my OAUTH flow:&lt;BR /&gt;The client will call this route witch should redirect the client to Dropbox authorization page:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    async get(req, res) {
        const usuario = await Usuario.findByPk(req.params.usuario_id);

        return res.redirect(
            `https://www.dropbox.com/oauth2/authorize?client_id=${process.env['APP_KEY']}&amp;amp;response_type=code&amp;amp;redirect_uri=${process.env.DROPBOX_WEBHOOK_URL}&amp;amp;token_access_type=offline&amp;amp;state=unidade_id:${usuario.unidade_id}`
        );
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the user authorizing my app the code bellow is called witch is the code for the route provided in the redirect_uri query param:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    async index(req, res) {
        const params = new URLSearchParams();
        params.append('code', req.query.code);
        params.append('client_id', process.env['APP_KEY']);
        params.append('client_secret', process.env['APP_SECRET']);
        params.append('grant_type', 'authorization_code');

        params.append('redirect_uri', process.env.DROPBOX_WEBHOOK_URL);

        const fronURLRedirect = new URL(
            '/dropbox',
            process.env['APP_FRONT_URL']
        );
        try {
            const { data } = await axios.post(
                process.env['DROPBOX_OAUTH2_TOKEN_ROUTE'],
                params
            );

            const [_, unidade_id] = req.query.state.split(':');

            await AcessoDropbox.create({
                ...data,
                update_token_date: new Date(),
                unidade_id,
            });

            fronURLRedirect.pathname = '/dropbox/sucesso';
            return res.redirect(fronURLRedirect.href);
        } catch (error) {
            console.log(error);

            fronURLRedirect.pathname = '/dropbox/erro';
            return res.redirect(fronURLRedirect.href);
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And after that our app is successfully authorized, at least during development, here is the return value that i receive from my POST call in the code above in development:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_0-1695329213423.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40700iD4DFAC173B4D1ACD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_0-1695329213423.png" alt="us0p_0-1695329213423.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And here is an example of what i receive back in QA with the same code, same app key and secret, the only difference is the redirect_uri:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_2-1695329318871.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40702i45A00F77F135B861/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_2-1695329318871.png" alt="us0p_2-1695329318871.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Here is a full print of my debugging:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_5-1695329485595.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40705iD821BE980C9ECA42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_5-1695329485595.png" alt="us0p_5-1695329485595.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm also receiving the query params as it should:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="us0p_3-1695329405356.png" style="width: 400px;"&gt;&lt;img src="https://www.dropboxforum.com/t5/image/serverpage/image-id/40703i7CACEF2C53223D85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="us0p_3-1695329405356.png" alt="us0p_3-1695329405356.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It looks like i'm receiving a binary as a response witch is totally different from what i was receiving during my tests, i searched the docs and did some googling but no luck!&lt;/P&gt;
&lt;P&gt;My Dropbox app isn't applied to production, i'm wondering if that's the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 21:39:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/715523#M31683</guid>
      <dc:creator>us0p</dc:creator>
      <dc:date>2023-09-21T21:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: /oauth2/token route is returning a binary in response</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/715676#M31693</link>
      <description>&lt;P&gt;Thanks for the detailed post!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 'development' versus 'production' &lt;A href="https://www.dropbox.com/developers/reference/developer-guide#production-approval" target="_blank"&gt;status&lt;/A&gt; of your app affects how many accounts can be connected to your app but it doesn't affect the content types/encodings of the messages returned by the API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does your development environment have a different version or configuration of 'axios' than your QA environment? It looks like network client in the QA environment may be encoding/decoding the response differently. For instance, it seems like your client may be requesting a content-encoding like gzip, but then not decompressing the response with the gzip content-encoding and instead just showing you the compressed content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you print the headers for both the request and response? That may be useful in debugging this. Be sure to redact any secret values though.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 13:29:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/715676#M31693</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-22T13:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: /oauth2/token route is returning a binary in response</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/716368#M31729</link>
      <description>&lt;P&gt;Hey Greg, thanks for your reply and sorry the dalay!&lt;BR /&gt;&lt;BR /&gt;I did as you suggested and printed the headers for both environments and they were pretty much the same, the only difference were in the request headers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Request Headers Development
 AxiosHeaders {
  Accept: 'application/json, text/plain, */*',
  'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
  'Accept-Encoding': 'gzip, compress, deflate, br',
  'User-Agent': 'axios/1.3.3',
  'Content-Length': '240'
}

// Request Headers QA
 AxiosHeaders {
  Accept: 'application/json, text/plain, */*',
  'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
  'User-Agent': 'axios/1.2.0',
  'Content-Length': '199',
  'Accept-Encoding': 'gzip, deflate, br'
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Response Headers - Dev 
AxiosHeaders {
  'cache-control': 'no-cache, no-store, must-revalidate',
  expires: '0',
  pragma: 'no-cache',
  'x-content-type-options': 'nosniff',
  'x-frame-options': 'SAMEORIGIN',
  'x-server-response-time': '216',
  'content-type': 'application/json',
  'accept-encoding': 'identity,gzip',
  date: 'Mon, 25 Sep 2023 18:50:34 GMT',
  server: 'envoy',
  vary: 'Accept-Encoding',
  'x-dropbox-response-origin': 'far_remote',
  'x-dropbox-request-id': '75143489d10744ea8ef2f4a1175eda99',
  connection: 'close',
  'transfer-encoding': 'chunked'
} 

// Response Headers - QA
 AxiosHeaders {
  'cache-control': 'no-cache, no-store, must-revalidate',
  expires: '0',
  pragma: 'no-cache',
  'x-content-type-options': 'nosniff',
  'x-frame-options': 'SAMEORIGIN',
  'x-server-response-time': '510',
  'content-type': 'application/json',
  'accept-encoding': 'identity,gzip',
  date: 'Mon, 25 Sep 2023 14:49:36 GMT',
  server: 'envoy',
  vary: 'Accept-Encoding',
  'x-dropbox-response-origin': 'far_remote',
  'x-dropbox-request-id': '9e5db6680a4542648248855fc72ff50d',
  connection: 'close',
  'transfer-encoding': 'chunked'
} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as you can see the difference is only in the Request Headers, in the Accept-Encoding and User-Agent headers, altough the version of Axios in both environments is the same, the user agent is different.&lt;BR /&gt;I added a Accept-Encoding header like the one i'm using in Dev, but still the same&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 19:04:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/716368#M31729</guid>
      <dc:creator>us0p</dc:creator>
      <dc:date>2023-09-25T19:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: /oauth2/token route is returning a binary in response</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/716402#M31732</link>
      <description>&lt;P&gt;Can you clarify what you mean when you say "altough the version of Axios in both environments is the same, the user agent is different"? The "user-agent" request header value being set by the client does seem to indicate that a different version number of Axios is being used in each case.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 20:26:29 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/oauth2-token-route-is-returning-a-binary-in-response/m-p/716402#M31732</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-25T20:26:29Z</dc:date>
    </item>
  </channel>
</rss>

