Quite likely missing something obvious, trying to migrate to the short-lived access tokens, so first change the authorize:
authorizeFromControllerV2
save the refresh token:
_dropbox.accessToken = authResult.accessToken.accessToken;
_dropbox.refreshToken = authResult.accessToken.refreshToken;
at a later date, init the UserClient
DBUserClient *dropboxClient = [[DBUserClient alloc] initWithAccessToken:_dropbox.accessToken];
But we can't supply a refresh token with this init method, so we should use
initWithAccessTokenProvider:
and implement id<DBAccessTokenProvider>
/// Protocol for objects that provide an access token and offer a way to refresh (short-lived) token.
@protocol DBAccessTokenProvider <NSObject>
/// Returns an access token for making user auth API calls.
@property (nonatomic, readonly) NSString *accessToken;
/// This refreshes the access token if it's expired or about to expire.
/// The refresh result will be passed back via the completion block.
- (void)refreshAccessTokenIfNecessary:(DBOAuthCompletion)completion;
@end
I notice this is already implemented within the SDK in "DBAccessTokenProvider+Internal.h" but this isn't exposed, are we not expected to use this init? Or is the play to just init with a normal accessToken and capture an error then refresh manually ourselves? Seems odd seeing as it's already in the SDK. What am I missing?