We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
phunction
3 years agoHelpful | Level 5
iOS 17.x can no longer login and allow dropbox access on app
i, something has changed with iOS 17. My app is using the DropboxClient() api to get an auth token, which would show safari and ask for a login. The login works, and they will get the question if t...
phunction
2 years agoHelpful | Level 5
I am trying to get this work with my iOS app, I have an redirect uri of myapp://oauth2redirect
However, I am unable to use it as my dropbox account wants me to use a uri of https:
What am I missing here? How do I get pkce to work without having to have some kind of webserver setup?
When I try to start the authflow, the dropbox website gives me the error:
Error 400: Invalid redirect uri. It must exactly match one of the redirect uris you've preconfigured for your app (including the path).
I use
var authorizeUrl = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Code, appKey, pkceuri, state: state, tokenAccessType: TokenAccessType.Offline, codeChallenge: codeChallenge);
Greg-DB
Dropbox Community Moderator
2 years agophunction The particular error message you shared here is referring to the redirect URI not being registered for the app; it isn't referring to the protocol (such as "https://" or "myapp://").
Whether using PKCE or not, the redirect URI value (the "pkceuri" variable in your code) must exactly match one of the redirect URIs registered for the app (based on the app key being used, the "appKey" variable in your code) on the App Console. If the redirect URI does not match exactly, you'll get that error message. To fix that, sign in to the account that owns the app (if you're not already) and register the relevant redirect URI using the "OAuth 2" "Redirect URIs" section of the app's page on the App Console.
It may be helpful to print out the values of "appKey" and "pkceuri" to double check you're registering the exact redirect URI for the relevant app.
- phunction2 years agoHelpful | Level 5
I have my pkce redirect setup at mytestapp://oauth2redirect
I entered that into the app console (I was mistaken that the uri had to have https:)
When I send the request, I now get the page asking if I want to authorize the app, when I say ok, it just gives me a string to enter into my app, it does not appear to automatically redirect.
Does this work when debugging?
I am not sure how the redirect works, when the browser opens and you authorize, does the browser now send back a message to iOS with the redirect URI, and iOS should see that the app has registered that uri in the info.plist then pass the returned info to the app?
- Greg-DB2 years ago
Dropbox Community Moderator
The redirect URI functionality works the same way regardless of whether you're debugging or if your app is in development or production status.
If the authorization page is showing the authorization code to the user on the authorization page (with a message like "Enter this code into ... to finish the process") then that means that a redirect URI wasn't used. If that's not what you intended, make sure you're still setting a redirect URI when building the authorization URI.
And yes, when using a redirect URI, after the user authorizes the app, Dropbox will redirect the user's browser to the specified redirect URI with the authorization code included. When using a custom URI scheme (like "myapp://" or "mytestapp://" in your examples), the browser and operating system handle that redirect to send it to the right place. For example, as you said, iOS would see which app has that particular scheme registered and would send that redirect to that app.
- phunction2 years agoHelpful | Level 5
Turns out I has an extra space in my auth uri.
I have it working now, thanks for all the help.
About 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!