Find your content:

Search form

You are here

Using a login page for OAuth with a hybrid mobile app


Is it possible to use a login page, e.g., to authenticate users with the PhoneGap OAuth plugin?

The plugin is called from javascript using:

PhoneGap.exec(success, fail, "com.salesforce.oauth", "authenticate", [JSON.stringify(oauthProperties)]);

Passing the login domain in oauthProperties would seem to be the place to set it. I found this changeset which removed oauthLoginDomain from oauthProperties:

Is oauthLoginDomain still supported by the plugin, or is there a new way of doing this?

Attribution to: xn.

Possible Suggestion/Solution #1

Edited to reflect the fact that Salesforce Mobile SDK is in play

The user can add a custom login host in the settings for their app (on iOS, from the home screen, Settings | Your App | Custom Host) and select it as the current login host.

So, the user can, in principle, add as a custom host and select it for use. You can also add My Domain hostnames such as - useful to have SAML work during the login.

I can't guarantee it will work with in particular, but it certainly does work with - I've tried that login URL in the desktop Chatter app that uses the same OAuth flow.

Now, if you want to do all this without the user getting involved, it looks like you can edit shared/Classes/Security/SFAccountManager.m - lines 45, 46 in the current Mobile SDK for iOS:

// Value to use for login host if user never opens the app settings.
NSString * const kDefaultLoginHost = @"";

In the current Android version, lines 100, 101 of native/SalesforceSDK/src/com/salesforce/androidsdk/auth/

// Login URLs / paths
public static final String DEFAULT_LOGIN_URL = "";

Attribution to: metadaddy
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content