4

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.

Pwner
  • 3,714
  • 6
  • 41
  • 67

1 Answers1

11

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.

Greg
  • 3,731
  • 1
  • 29
  • 25
  • I use this format in the field, but only works on iOS not Android. And I can't leave the field blank. – CopperCash Dec 17 '14 at 08:09
  • @greg, I did same process but its doesn't worked for me. I set redirect_uri - https://api.box.com/oauth2/authorize?response_type=code&client_id= MY_CLIENT_ID&state=ok&redirect_uri=boxsdk-MY_CLIENT_ID%3A%2F%2Fboxsdkoauth2redirect. Please suggest... – Bhanu Jan 08 '15 at 07:56
  • 1
    @greg, And after almost one year, mistake is still in your documentation: https://developers.box.com/authentication-in-your-ios-app/ – Farhad Malekpour Apr 13 '15 at 06:57
  • Sorry @FarhadMalekpour, this must've fallen through the cracks. We'll soon be releasing a vastly improved iOS SDK which should make the authentication process a lot simpler and have much better documentation. – Greg Apr 13 '15 at 07:09
  • @Greg could you call people or mail them to create a clear example. I'm working for 3 days to make this redirect_uri going. Thanks for you answer it possibly saved my countless hours. – Ersin Sezgin Aug 06 '16 at 15:27