We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

nevermindx's avatar
nevermindx
Explorer | Level 4
3 months ago

Drop box js sdk

 
this.dbxAuth = new DropboxAuth({
clientId: dropboxConfig.clientId,
clientSecret: dropboxConfig.clientSecret,
})
 
i am stroing the refreshToken from 
const tokenResponse = await this.dbxAuth.getAccessTokenFromCode(
  dropboxConfig.redirectUri,
  code,
) this method .
 
const scopes = [
'account_info.read',
'file_requests.read',
'file_requests.write',
'files.content.write',
'files.metadata.read',
]

const dbx = new DropboxAuth({
refreshToken: refreshToken,
clientId: dropboxConfig.clientId,
clientSecret: dropboxConfig.clientSecret,
})

 refreshedToken = await dbx.refreshAccessToken(scopes
 
but not able to refresh token . 
error: {
   error: 'invalid_request',
   error_description: 'No auth function available for given request'
 }
actually do we need to refresh ? it is so confusing. the docs also makes no sense to me.

  • nevermindx wrote:
    ...
    actually do we need to refresh ? ...

    NO, actually you do not. The mentioned method gets executed internally whenever needed. Just init your Dropbox object with the instance of DropboxAuth, you already have (as discussed in the other thread), and... that's it - further do call methods there according what you need to do - Dropbox object' methods only. 😉

    Hope this helps.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    nevermindx wrote:
    ...
    actually do we need to refresh ? ...

    NO, actually you do not. The mentioned method gets executed internally whenever needed. Just init your Dropbox object with the instance of DropboxAuth, you already have (as discussed in the other thread), and... that's it - further do call methods there according what you need to do - Dropbox object' methods only. 😉

    Hope this helps.

    • nevermindx's avatar
      nevermindx
      Explorer | Level 4

      Thank you for the support🤝

       

      Sorry if this seems like a basic question. Could you explain the situations in which we should use the refreshAccessToken() and checkAndRefreshToken() functions?

    • Здравко's avatar
      Здравко
      Legendary | Level 20

      Здравко wrote:

      nevermindx wrote:
      ...
      actually do we need to refresh ? ...

      NO, actually you do not. The mentioned method gets executed internally whenever needed. ...


      Hm... What's not clear enough. 🤔 The conclusions seems clear enough (at least to me), but I will say it explicitly: NEVER - you don't need to call either refreshAccessToken or checkAndRefreshAccessToken by your own. By the way refreshAccessToken is called by checkAndRefreshAccessToken and checkAndRefreshAccessToken is called by all request calls of Dropbox class.

       

      Edit: Little extrapolation was here. Actually it's not called by all request calls. Calls that need application authentication don't make such a call (actually there is a call but result is ignored - little imperfection here) because... it's just not needed - there neither access token nor refresh token are in use. I'm saying this just for completeness.

About Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,875 PostsLatest Activity: 4 hours ago
323 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!