+ Start a Discussion
jschmidjschmid 

Custom authentication flow on a native iOS app

(Note: I am not talking about changing the view itself, but the URI that is shown in the webview)

 

Hi,

 

When the user opens the iOS app, we want to handle ourselves the oAuth flow. We want to open the UIWebview, direct the user to our own backend, which will do a redirection with the SF oAuth and handle the responses our way.

 

Is it supported to do something like:

 

    SFOAuthCredentials *creds = [SFAccountManager sharedInstance].credentials;
    
    creds.identityUrl    = [NSURL URLWithString:@"https://login.salesforce.com/id/00Dc0000000KRZPEA4/005u0000000iOa1AeE"];
    creds.accessToken    = @"00Db0000000KRZP!ASAAQFhhTqaZlmehuUwpvSAYpC.wZDvCKTc1sEGErpglNqW9MCvMIPNRHIuHvCp8zlasPBhdodenRi1QAbI2m6ueEDsxX5md";
    creds.refreshToken   = @"5Aep861rSrJOsYD8snR04Dhmvr79hrip9qTsozctzwwh9ZTergft.m07BbyfXRhz6E.mCF9T9F.RKcHH1Ti.Vh6";
    creds.instanceUrl    = [NSURL URLWithString:@"https://eu2.salesforce.com"];
    creds.issuedAt       = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
    
    [[SFAuthenticationManager sharedManager] loginWithCompletion:... failure:...];

The tokens are sent by our own backend, then we to the login part.

 

Is that ok?

Thanks

 

Gaurav KheterpalGaurav Kheterpal

I am not sure what you are trying to do with the code snippet you mentioned.

 

This is doable, the native template creates an option to choose a custom host in addition to Sandbox and Production. Users can then switch to the custom URL auth by choosing Settings.-> <Your App> -> Host -> Custom Host

 

 

jschmidjschmid

Thank you for the reply.
I might not have explained correctly.

I do not want to use the login flow that the native app proposes. I want to open a UIWebView by myself, do a bunch a things on my own webserver first, then redirect to the SF oAuth server. The oAuth process will have a callback URL to my own web server which will itself handle the returned oAuth token and give it back to my application.

I then need to feed those credentials to the SF SDK in order to use it. I would like to know if the snippet I use is supported or not.
Thanks a lot