<?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 Re: Need help generating a pkce refresh token in a javascript PWA in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528210#M1961</link>
    <description>&lt;P&gt;Yes, if you need long-term access without having the user re-authorize, you should request "offline" access to get and use a refresh token to get new short-lived access tokens as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's &lt;A href="https://github.com/dropbox/dropbox-sdk-js/tree/main/examples/javascript/PKCE-backend" target="_self"&gt;a "PKCE-backend" example&lt;/A&gt; that shows how you can &lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/PKCE-backend/code_flow_example.js#L24" target="_self"&gt;request this kind of access&lt;/A&gt;, and then &lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/PKCE-backend/code_flow_example.js#L38" target="_self"&gt;set the resulting refresh token&lt;/A&gt; using &lt;A href="https://dropbox.github.io/dropbox-sdk-js/global.html#setRefreshToken" target="_self"&gt;setRefreshToken&lt;/A&gt;. The SDK will then automatically handle the refresh process for you when needed.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jun 2021 15:38:50 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2021-06-21T15:38:50Z</dc:date>
    <item>
      <title>Need help generating a pkce refresh token in a javascript PWA</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528083#M1958</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi folks, I'm running into some trouble with the new authentication flow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got a single page, severless JS PWA and I want to use Dropbox to store the user's data without forcing them to authenticate every four hours or each time they re-open the app. I've been using the old oauth flow and storing the long-lived token in localstorage and it's been fine, but I'm unclear about what to store from the pkce flow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd ideally like to store the refresh token in localstorage and use that to generate short-lived tokens as needed, but the documentation isn't quite clear. I'm trying to follow the example in the js sdk for generating a token (&lt;/SPAN&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/pkce-browser/index.html" target="_blank" rel="nofollow noopener"&gt;https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/pkce-browser/index.html&lt;/A&gt;&lt;SPAN&gt;), but this example only shows the initial authentication: sending the user to the authentication page, and retrieving the first short-lived token&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(line 97). It doesn't show how to use the refresh token to generate subsequent tokens.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that in the response from dbxAuth.getAccessTokenFromCode includes the refresh token (line 96 and line 97), but I'm not quite sure how to generate short-lived tokens with it. I see in the sdk there's a function called checkAndRefreshAccessToken() that returns a promise, but it's returning empty when I call it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TLDR: How do I alter this example (&lt;/SPAN&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/pkce-browser/index.html" target="_blank" rel="nofollow noopener"&gt;https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/pkce-browser/index.html&lt;/A&gt;&lt;SPAN&gt;) to store the refresh token and use it to generate short-lived tokens down the road?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 06:06:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528083#M1958</guid>
      <dc:creator>seenigel</dc:creator>
      <dc:date>2021-06-21T06:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help generating a pkce refresh token in a javascript PWA</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528210#M1961</link>
      <description>&lt;P&gt;Yes, if you need long-term access without having the user re-authorize, you should request "offline" access to get and use a refresh token to get new short-lived access tokens as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's &lt;A href="https://github.com/dropbox/dropbox-sdk-js/tree/main/examples/javascript/PKCE-backend" target="_self"&gt;a "PKCE-backend" example&lt;/A&gt; that shows how you can &lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/PKCE-backend/code_flow_example.js#L24" target="_self"&gt;request this kind of access&lt;/A&gt;, and then &lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/PKCE-backend/code_flow_example.js#L38" target="_self"&gt;set the resulting refresh token&lt;/A&gt; using &lt;A href="https://dropbox.github.io/dropbox-sdk-js/global.html#setRefreshToken" target="_self"&gt;setRefreshToken&lt;/A&gt;. The SDK will then automatically handle the refresh process for you when needed.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 15:38:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528210#M1961</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2021-06-21T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help generating a pkce refresh token in a javascript PWA</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528807#M1972</link>
      <description>&lt;P&gt;Thanks so much! That solved it!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message for future PWA developers: the solution is a mash-up of the browser frontend example (&lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/pkce-browser/index.html" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/pkce-browser/index.html&lt;/A&gt;) and the node backend example.&amp;nbsp; (&lt;A href="https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/PKCE-backend/code_flow_example.js" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-js/blob/main/examples/javascript/PKCE-backend/code_flow_example.js&lt;/A&gt;). Once you store the refresh token, the api will take care of all the short-lived tokens automatically.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 02:27:00 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-help-generating-a-pkce-refresh-token-in-a-javascript-PWA/m-p/528807#M1972</guid>
      <dc:creator>seenigel</dc:creator>
      <dc:date>2021-06-24T02:27:00Z</dc:date>
    </item>
  </channel>
</rss>

