Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get a redirect URI mismatch when trying to log into Box?

When using the Box SDK for iOS to do OAuth, I am shown a webpage with this error:

enter image description here

Error: redirect_uri_mismatch

response_type=code redirect_uri=boxsdk-our4iypzazstfpx8j70e8tlc3eyn9c4l://boxsdkoauth2redirect state=ok client_id=our4iypzazstfpx8j70e8tlc3eyn9c4l

I used the code that they suggested:

[self
    presentViewController:[[BoxAuthorizationViewController alloc]
        initWithAuthorizationURL:[[BoxSDK sharedSDK].OAuth2Session authorizeURL]
        redirectURI:nil
    ]
    animated:YES
    completion:nil
];

My client ID and client secret are set prior to this. In my info.plist file, I have boxsdk-our4iypzazstfpx8j70e8tlc3eyn9c4l as a URL scheme. The only instruction I could not follow is:

Note: When setting up your service on Box, leave the OAuth2 reditrect URI blank. The SDK will provide a custom redirect URI when issuing OAuth2 calls; doing so requires that no redirect URI be set in your service settings.

When I attempt to leave the redirect URI blank and save the form in the developer console, I get the this error:

OAuth2 redirect URL must specify a valid URL and must not be http://

So I am forced to input something. I have inputted "https://mydomain.com" (with my real domain). I modified the iOS code to pass that URI into the BoxAuthorizationViewController, but I still get the same error webpage.

like image 782
Pwner Avatar asked Dec 20 '22 12:12

Pwner


1 Answers

Sorry, this was a mistake in our documentation. It should work if you enter boxsdk-YOUR_CLIENT_ID://boxsdkoauth2redirect into the developer console for your redirect_uri, replacing YOUR_CLIENT_ID with your actual client ID.

like image 54
Greg Avatar answered Apr 08 '23 14:04

Greg