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
sujesh.ramachandransujesh.ramachandran 

Landing Visualforce page Issue in Hybrid Mobile App

Hi,

 

I am new to Mobile Apps development. I am trying to access "testPage" in my salesforce instance from Hybrid App. Below the code to land on visualforce page after successful login.

 

var startData = new SFHybridApp.RemoteAppStartData("/apex/testPage");

 

After successful login, its trying to connect the above page and showing the below error in the login page :

 

"You have attempted to access a page that requires a salesforce.com login. If you are already a user of the system, please login below."

 

But if I am trying to access a local page in mobile, It's successfully login, Below is the code I have used for accessing local page in mobile :

var startData = new SFHybridApp.LocalAppStartData();

 

Could let me where I am going wrong...

 

Regards,

Sujesh

 

Best Answer chosen by Admin (Salesforce Developers) 
Kevin HawkinsKevin Hawkins

My first thought is that the OAuth scopes are not right.  This behavior usually manifests if your requested OAuth scopes are insufficient to grant permission to the page.  Your OAuth scopes should be, at a minimum, "web" and "api".

 

If that's not the issue, then what happens when you try to connect to the page in a browser, with the same user?  E.g. put https://login.salesforce.com/apex/testPage into your browser and authenticate from there.

All Answers

Kevin HawkinsKevin Hawkins

My first thought is that the OAuth scopes are not right.  This behavior usually manifests if your requested OAuth scopes are insufficient to grant permission to the page.  Your OAuth scopes should be, at a minimum, "web" and "api".

 

If that's not the issue, then what happens when you try to connect to the page in a browser, with the same user?  E.g. put https://login.salesforce.com/apex/testPage into your browser and authenticate from there.

This was selected as the best answer
sujesh.ramachandransujesh.ramachandran

Hi Kevin,

 

I am using the below oAuth Scope.

 

var oauthScopes = ["api"];

 

When i tried https://login.salesforce.com/apex/testPage in browser and authenticated with the same user. I am able to see the page properly in browser.

 

Any guess where I am going wrong?

 

Thanks,

Sujesh

Kevin HawkinsKevin Hawkins

You need to additionally use the "web" scope.  The hybrid authentication process requires the web scope, for initializing the hybrid auth state of the app.

sujesh.ramachandransujesh.ramachandran

Thank you Kevin!!!

 

 

I have added Web to the oAuth Scopes and its started working!!!

var oauthScopes = ["web", "api"];

 

Regards,

Sujesh

sujesh.ramachandransujesh.ramachandran

Thank you Kevin!!!

 

 

I have added Web to the oAuth Scopes and its started working!!!

var oauthScopes = ["web", "api"];

 

Regards,

Sujesh