7

Is it possible to use a cloudforce.com login page, e.g. https://example.cloudforce.com, 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: https://github.com/forcedotcom/SalesforceMobileSDK-Shared/commit/2bb43033f2806cb5b827dd940c42eab09a7c3276

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

1 Answer 1

7

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 example.cloudforce.com as a custom host and select it for use. You can also add My Domain hostnames such as mycompany.my.salesforce.com - useful to have SAML work during the login.

I can't guarantee it will work with example.cloudforce.com in particular, but it certainly does work with dreamevent.my.salesforce.com - 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 = @"login.salesforce.com";

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

// Login URLs / paths
public static final String DEFAULT_LOGIN_URL = "https://login.salesforce.com";
10
  • Thanks. I'm using the Mobile SDK. I've updated the question to clarify.
    – xn.
    Aug 31, 2012 at 19:15
  • @xn. I've updated the answer to reflect your update.
    – metadaddy
    Aug 31, 2012 at 19:49
  • do you know where I would need to make the change for the Android version of the Mobile SDK?
    – xn.
    Aug 31, 2012 at 20:13
  • 1
    It works, but the branding doesn't appear on the OAuth login page. For example, compare greatvines.cloudforce.com/?display=mobile and greatvines.cloudforce.com/services/oauth2/…
    – xn.
    Sep 1, 2012 at 2:31
  • 1
    Looks like it's been fixed. Thanks again, @metadata.
    – xn.
    Oct 17, 2012 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .