function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Josip Juric87Josip Juric87 

Hybrid Local app - Custom login page

Hi, is it possible to have a custom login page in a hybrid local app?
I have tried to use the technique described in the Developer Guide p. 257, i.e. changing the login URL to a community login which can be customized. It works, but then the app ends up in the community itself, and not back in the app (in the index.html file of the app), as expected.
Am I doing something wrong? Should I customize the login page in some other fashion?
Gaurav KheterpalGaurav Kheterpal
Have you created a connected app with an appropriate callback URL?

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker
Josip Juric87Josip Juric87
I do have a connected app, with "some" callback URL - I don't know if it's appropriate...
The callback url in the App-definition is: demo2:///mobilesdk/detect/oauth/done

In the bootconfig.json, I have the following:
{
  "remoteAccessConsumerKey": "(..my client secret..)",
  "oauthRedirectURI": "demo2:///mobilesdk/detect/oauth/done",
  "oauthScopes": [
    "web",
    "api"
  ],
  "isLocal": true,
  "startPage": "index.html",
  "errorPage": "error.html",
  "shouldAuthenticate": true,
  "attemptOfflineLoad": false
}
 
Gaurav KheterpalGaurav Kheterpal
Do you mind sharing your custom login page code as well? Are you using the Site.login Apex call?

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker
Sachin Tiwari 19Sachin Tiwari 19
Hi,
What i will suggest is the use of all oAuth scope in your bootconfig.json file
try using below line in place of your existing code:
"api","web","full","chatter_api","visualforce","openid","custom_permissions","refresh_token","offline_access"

and yes try to give a simple url there is no need to use same which is being provided in devloper guide. You can use something like
sfdc://success

Try this and let me know once your done. Thanks.
Josip Juric87Josip Juric87
@Gaurav: I'm used the standard Community login page, just with branding.
@Sachin: I have tried both, but did not help.

Do I have to configure anything in the "Mobile App Settings" section of the connected-app definition?
Sachin Tiwari 19Sachin Tiwari 19
did you provide the same oauth scope in your connected app? Cross check once and if not then provide all and then wait for sometime and then run your application via eclipse.
Josip Juric87Josip Juric87
I have added all in the connected app definition, and in the bootconfig:
{
...
  "oauthScopes": [
    "api","web","full","chatter_api","visualforce","openid","custom_permissions","refresh_token","offline_access",
    "id", "profile", "email", "address", "phone"
  ],
  ...
}

Also, I'm running it as an iOS app through xCode, but that should not cause the problem :)
Josip Juric87Josip Juric87
Can anyone confirm if the functionality is working for him?
Josip Juric87Josip Juric87

OK, weird, but it is working now...

What I tried was to create a new community and it worked with the new one. Then I re-checked with the old one, and this one is also working now... Could be some caching, or something, or maybe the oauth scopes have not been applied yet before...

Anyway, thanks guys!

Gaurav KheterpalGaurav Kheterpal
There's definitely no delay in propagation of oAuth scopes but happy to hear that it's workign now.

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker
Sachin Tiwari 19Sachin Tiwari 19
Good to hear that josip. May be there was some unknown issue but its good that its working fine now. Can you tell me where you changed your  login page url ? specific file name?
Josip Juric87Josip Juric87
Sure, I changed it in the <project-name>--info.plist file, located in the Resource folder in XCode. There I added a key-value with key SFDCOAuthLoginHost and the URL as value. This is described in the Salesforce Mobile SDK Development Guide (SDK 3.1) on page 257 (chapter "Using Communities With Mobile SDK Apps ", subchapter "Configure the Login Endpoint ").