In API 1, I could offer the user an option to re-link (re-authorise) Dropbox if they run into issues because their access token had expired or been revoked. I could do this as follows:
First, I listened for the DBSession delegate method:
- (void)sessionDidReceiveAuthorizationFailure:(DBSession * )session userId:(NSString * )userId
Then, if I received this notification, I did two things:
1. Offer the user the chance to re-link Dropbox then and there (given that re-linking should be all that is required, as described in Core API Best Practises: <https://www.dropbox.com/developers-v1/core/bestpractices>).
2. Make note in a flag that there had been a session authorisation failure. Then, in a sync options menu, if this flag was YES, I would offer a "Re-Link Dropbox" option. In both cases, I could just call:
NSArray *userIds = [[DBSession sharedSession] userIds];
if (userIDs.count > 0)
[[DBSession sharedSession] linkUserId:userIds[0] fromController:self];
Or, when calling this directly from the DBSession delegate method, I could pass in the userId directly because it was a parameter in the delegate method:
[[DBSession sharedSession] linkUserId:userId fromController:self];
What is the equivalent for re-linking following an authorisation failure owing to a revoked or expired access token in API 2?
At first I thought it was DropboxClientManager's -reauthorizeClient:, but that relies on grabbing the access token from [[DropboxClientsManager authorizedClient] transportClient].accessToken], and that won't be available (I believe) if authorisation has failed. And anyway, I believe this uses the very access token which has expired or been revoked in this situation. (In which case, what is -reauthorizeClient: for?)
Do I just call -authorizeFromController:controller:openURL:browserAuth: again to re-link in API 2, the same as for linking in the first place? Or is there a dedicated method like there was in API 1?
Thanks!
Keith