dropbox / dropbox-sdk-obj-c

Official Objective-C SDK for the Dropbox API v2.
MIT License
183 stars 117 forks source link

DropboxAuthError with error content "expired access token" #351

Closed rajubd49 closed 2 years ago

rajubd49 commented 2 years ago

Our iOS app is basically implemented using Objective C and we use ObjectiveDropboxOfficial to login to dropbox. The app was working fine for a long time, but for the past few days, we are facing an access token expiration issue. If we log in today and try to fetch files the next day, we are getting this error and we need to relink or login again for the dropbox to work.

Error log:

DropboxAuthError[{ ErrorContent = "expired_access_token/"; RequestId = 24a031d6ab81429eb0f714646cbf9f38; StatusCode = 401; StructuredAuthError = "{\n \".tag\" = other;\n}"; UserMessage = nil; }];

What is the solution or best way to resolve this issue?

tidrop commented 2 years ago

@rajubd49 It seems like you're experiencing short lived tokens expiring. The Obj-C SDK handles automatic refreshing of expired tokens. Please take a look at the example here for how this is implemented.

rajubd49 commented 2 years ago

@tidrop Thank you for your response, we've solved the issue.

tienjp68 commented 2 years ago

@rajubd49 I am also getting this error Can you show the solved code? Thank you very much!

rajubd49 commented 2 years ago

@tienjp68 My problem was, in podfile we did specified version 3.x.x which was not working anymore for short lived tokens expiring issue. So we've updated ObjectiveDropboxOfficial to it's latest version which is I believe 6.2.3 and it resolves our problem.

tienjp68 commented 2 years ago

@rajubd49 Thank you very much!

tienjp68 commented 2 years ago

@rajubd49 I have reinstalled pod but func "AuthozeFromControllerV2" is not in DBClientsManager+MobileAuth-iOS file, do you know why?

target 'Kodomomenkyo' do use_frameworks! pod 'ObjectiveDropboxOfficial' end

target 'Kodomomenkyo_dev' do use_frameworks! pod 'ObjectiveDropboxOfficial' end

greg-db commented 2 years ago

@tienjp68 Note that you have a typo in your comment; make sure you don't also have the same typo in your code. The method is named "authorizeFromControllerV2" not "AuthozeFromControllerV2". The authorizeFromControllerV2 method is defined here in DBClientsManager+MobileAuth-iOS.m.

Make sure you actually have a recent version of the SDK installed, ideally the latest version, which is currently v6.3.2. It looks like you're using CocoaPods, so you can use pod update to update. Check the output to make sure that runs successfully and to check that the latest version is installed.

Then, you can set up the authorization flow as documented.

If something still isn't working as expected, feel free to open a new issue with the details of the issue.

tienjp68 commented 2 years ago

@greg-db Cause is missing: platform :ios, '9.0' Thank you very much!