Forum Discussion

SneYellow46's avatar
SneYellow46
Explorer | Level 4
4 years ago

Getting refreshed access token from Generated access tokem

Hi,

I have an iOS objective c application connected with dropbox SDK.

 

We are using generated access token to access apps folder from my BD account.

 

 

 

client = [[DBUserClient alloc] initWithAccessToken:@"sl.BThRWss....."];

 

 

 

But this Generated access token expires after sometime. What is the possible solution so that it doesnt expire or get a refreshed access token.

Note that we need to use the generated access token approach other than oAuth flow. 

Can you provide any code sample in Objective c to get this refreshed token or how we can achieve this?

 

Thanks,

14 Replies

Replies have been turned off for this discussion
  • Здравко's avatar
    Здравко
    Legendary | Level 20
    4 years ago

    SneYellow46 wrote:

    ...

    I know that using oAuth flow tokens are refreshed automatically by DB SDK. But in my case what is the solution?

    ...


    The same. 😉 Once you get to the authentication info just save it and embedding. That's it. Take a look on the description if you have something forgotten.

  • SneYellow46's avatar
    SneYellow46
    Explorer | Level 4
    4 years ago

    Hi Здравко ,

    i get refreshed token using this , and i believe refresh tokens doest expire.

    How I can make the DBUserClient, initWithAccessToken call with this refresh token to get access to my dropbox.

    similar to , 

     client = [[DBUserClient alloc] initWithAccessToken:@"I5wqb1d...."];

    Can you provide any code sample in objective c to do this? I found with methods with initWithAccessToken which takes in refresh token param but didn't understand much of it.

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

    SneYellow46 wrote:

    ...

    How I can make the DBUserClient, initWithAccessToken call with this refresh token to get access to my dropbox.

    similar to ,

     client = [[DBUserClient alloc] initWithAccessToken:@"I5wqb1d...."];

    ... I found with methods with initWithAccessToken which takes in refresh token ...

    No unfortunately, the method 'initWithAccessToken' (any of them) doesn't provide so simple way (don't ask me why; if I have to bet, it's cause Obj-C supposes to be used for client side apps - i.e. with OAuth flow). The method mentioned doesn't receive refresh token directly as a string, but does accept token provider object which on its own can be initialized with 'DBAccessToken' object (don't ask me why this class names so). The last object can represent variety authentication info (non restricted to simple access token).

    So first you can create 'DBAccessToken' object using appropriate constructor. Next a client object initialization can be done as performed here. Warning: Select proper transport config, matching to the way that you have used for the refresh token (it's good idea to get a refresh token using PKCE instead)! Mistake for the methods in use will make refresh fails.

    Good luck.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!