+ Start a Discussion

iOS Native Oauth SDK returning "An exception has occurred. You were idle for too long."

Hey all, any help would be appreciated.

Attempting to integrate the SalesForce iOS Native SDK into an application to tie into some web functionality for a client, but having an issue. The goal is to use the OAuth ability to log in the user, then present with a custom web view in iOS and Android, which allows the user to access this web panel without the need to re-login.

We are able to authenticate the user via OAuth and get a token, but when we attempt to send the user to the correct web URL, we're seeing an error that offers the following error message:

"An Exception has Occurred - You were idle for too long. For security reasons, please sign out and then sign back in."

I think it may have something to do with this?

Anyone have any suggestions?
We are sending the token in the header for field "Authorization" and the object is "Bearer $token"
Kevin HawkinsKevin Hawkins
To convert an OAuth session into a web session, it would probably be easiest to take a look at what the Mobile SDK does for its hybrid apps.  You could approach this in one of two ways:

If your hybrid/web view inherits from SFHybridViewController in the SalesforceHybridSDK, you can get the conversion "for free"; you just specify the configuration values such as the page you're attempting to load, etc., as part of the initialization of the view controller.

If you want to go with your own parent view controller, you can load your page by going through frontdoor.jsp. providing the OAuth access token value as the "sid" parametmer, and providing your page's URL as the "retURL" parameter.  You can take a look at [SFAuthenticationManager frontDoorUrlWithReturnUrl:returnUrlIsEncoded:] to see how the hybrid SDK does it.  But it would basically look like this:

SFOAuthCredentials *creds = [SFAccountManager sharedInstance].credentials;
NSString *frontDoorUrl = [NSString stringWithFormat:@"%@/secur/frontdoor.jsp?sid=%@&retURL=%@&display=touch", [creds.instanceUrl absoluteString], creds.accessToken, @"/your/page/relative/url"];
UIWebView *webView = [[UIWebView alloc] initWithFrame:view frame];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:frontDoorUrl]]];