7

If you specify the 'web' scope for a connected app it's supposed to grant/provide access to Visualforce pages.

I'm authenticating via the iOS mobile SDK and then attempting to use the access token I get to open a Visualforce page inside of a web view.

The Current works-but-is-kinda-suboptimal approach

If I use the frontdoor.jsp script like this:

NSString *frontDoorUrl = [NSString stringWithFormat:@"%@/secur/frontdoor.jsp?sid=%@&retURL=%@&display=touch", [creds.instanceUrl absoluteString], creds.accessToken, path];

then I can access the page, everything works well, but it takes roughtly twice as long to load the intended page because it has to complete this request first.

The should-work-but-doesn't approach

You're supposed to be able to use the access token as a parameter in a Visualforce URL, but this doesn't work if I just use the value in creds.instanceUrl above as that gives a value such as https://na24.salesforce.com which means I generated a string like this:

https://na24.salesforce.com/apex/MyPage?oauth_token=<<access token>>

... and then the webview gets redirected to the login screen.

What does work is if I take the instance URL provided, and do some string replacements to point at the visualforce domain instead, i.e.

https://c.na24.visual.force.com/apex/MyPage?oauth_token=<<access token>>

... but that's for a given value of 'work'. If I throw such a URL into a browser then files from my static resources don't load, instead I'm getting back a page that's seemingly used to do some redirects:

<script>
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://login.salesforce.com/?ec=302&startURL=%2Fvisualforce%2Fsession%3Furl%3Dhttps%253A%252F%252Fc.na24.visual.force.com%252Fresource%252F1458526800%252Fscripts.js'); }  else 
if (window.location.replace){ 
window.location.replace('https://login.salesforce.com/?ec=302&startURL=%2Fvisualforce%2Fsession%3Furl%3Dhttps%253A%252F%252Fc.na24.visual.force.com%252Fresource%252F1458526800%252Fscripts.js');
} else {;
window.location.href ='https://login.salesforce.com/?ec=302&startURL=%2Fvisualforce%2Fsession%3Furl%3Dhttps%253A%252F%252Fc.na24.visual.force.com%252Fresource%252F1458526800%252Fscripts.js';
}

Before I try raising this as a bug with support, can anyone confirm whether or not I'm just doing something dumb/wrong here?

  • Did you ever open this one up with support? You're not doing anything obviously wrong as far as I can see. – Adrian Larson Aug 16 '16 at 13:03
  • No, perhaps I should have done but I talked with a few people inside of SFDC directly and they said the purpose of the front door is to ensure valid access to all possible resources and endpoints, and that it's the way to go. – Matt Lacey Aug 16 '16 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.