<?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 Cannot get Access Token via https://api.dropboxapi.com/oauth2/token! in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/567940#M2325</link>
    <description>&lt;P&gt;When I try to get an access Token using &lt;STRONG&gt;Fetch&lt;/STRONG&gt; in JavaScript via the in the title specified endpoint, it returns this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{"webSocket":null,"url":"https://api.dropboxapi.com/oauth2/token","redirected":false,"ok":true,"headers":{},"statusText":"OK","status":200,"bodyUsed":false,"body":{"locked":false}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    async function getInitial() {
      let dropBoxConnection = await fetch(`https://api.dropboxapi.com/oauth2/token`, {
        body: new URLSearchParams({
          code: dropToken,
          grant_type: 'authorization_code',
          redirect_uri: DropBoxData.redirect,
          client_id: DropBoxData.key,
          client_secret: DropBoxData.secret
        }),
        method: "POST"
      }).then((response) =&amp;gt; {
        return response;
      }).catch((error) =&amp;gt;  {
        return new Error(error);
      });

      return await dropBoxConnection;
    }

    if(dropToken) var DropboxReturn = await getInitial();

    return new Response("Old Token: " + dropToken + ";" + " API-Response: " + JSON.stringify(DropboxReturn));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jan 2022 20:10:00 GMT</pubDate>
    <dc:creator>jkdev</dc:creator>
    <dc:date>2022-01-03T20:10:00Z</dc:date>
    <item>
      <title>Cannot get Access Token via https://api.dropboxapi.com/oauth2/token!</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/567940#M2325</link>
      <description>&lt;P&gt;When I try to get an access Token using &lt;STRONG&gt;Fetch&lt;/STRONG&gt; in JavaScript via the in the title specified endpoint, it returns this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{"webSocket":null,"url":"https://api.dropboxapi.com/oauth2/token","redirected":false,"ok":true,"headers":{},"statusText":"OK","status":200,"bodyUsed":false,"body":{"locked":false}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    async function getInitial() {
      let dropBoxConnection = await fetch(`https://api.dropboxapi.com/oauth2/token`, {
        body: new URLSearchParams({
          code: dropToken,
          grant_type: 'authorization_code',
          redirect_uri: DropBoxData.redirect,
          client_id: DropBoxData.key,
          client_secret: DropBoxData.secret
        }),
        method: "POST"
      }).then((response) =&amp;gt; {
        return response;
      }).catch((error) =&amp;gt;  {
        return new Error(error);
      });

      return await dropBoxConnection;
    }

    if(dropToken) var DropboxReturn = await getInitial();

    return new Response("Old Token: " + dropToken + ";" + " API-Response: " + JSON.stringify(DropboxReturn));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 20:10:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/567940#M2325</guid>
      <dc:creator>jkdev</dc:creator>
      <dc:date>2022-01-03T20:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get Access Token via https://api.dropboxapi.com/oauth2/token!</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/568159#M2327</link>
      <description>&lt;P&gt;I see you're getting a 200 status code which should indicate that the call completed, but I don't see the actual response body here. Can you print out the response body? I can't offer help with fetch itself so you may need to refer to the fetch documentation for information on using it.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 16:31:51 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/568159#M2327</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-01-04T16:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get Access Token via https://api.dropboxapi.com/oauth2/token!</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/568169#M2328</link>
      <description>&lt;P&gt;I figured it out.. I used the wrong method to print out the response body. I printed out the Response, when I should've printed out Response.json().&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 17:09:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Cannot-get-Access-Token-via-https-api-dropboxapi-com-oauth2/m-p/568169#M2328</guid>
      <dc:creator>jkdev</dc:creator>
      <dc:date>2022-01-04T17:09:13Z</dc:date>
    </item>
  </channel>
</rss>

