You need to sign in to do that
Don't have an account?
Timur Khayaliev
Native iOS app. How to pass authorization token into Webview for a community users?
We created a simple iOS native app, which should allow users to login into SF once and then open Lightning community app in a Webview. For this purposes we have below steps:
1. User launch the mobile app;
2. App calls Mobile SDK, which redirects to community login page, where user enters login and password; That allows us to get and refresh session token if this is required.
3. We get an authorization token and passing community URL + token into WebView.
4. We tried to pass authorization token as a parameter like:
let request = try! URLRequest(url: URL(string: "<Link to community page>")!, method: .get, headers: ["Authorization" : "Bearer \(token!)"])
or using frontoor.jsp.
both ways works fine when I try to open classic SF page or application. But when I try to open Community page it asks login again. So that means that those ways does not work with a community pages.
So how can I pass authorization token to a Webview for a community users? Any help would be appreciated! Thanks!
1. User launch the mobile app;
2. App calls Mobile SDK, which redirects to community login page, where user enters login and password; That allows us to get and refresh session token if this is required.
3. We get an authorization token and passing community URL + token into WebView.
4. We tried to pass authorization token as a parameter like:
let request = try! URLRequest(url: URL(string: "<Link to community page>")!, method: .get, headers: ["Authorization" : "Bearer \(token!)"])
or using frontoor.jsp.
both ways works fine when I try to open classic SF page or application. But when I try to open Community page it asks login again. So that means that those ways does not work with a community pages.
So how can I pass authorization token to a Webview for a community users? Any help would be appreciated! Thanks!
Kindly let me know no what to do in order to make the community pages open on the app without assigning for login again
use the frontdoor url and call VF Page which redirect to SFDC Commnunity
an VF page
<apex:page controller="xxx " action="{!redirect}">
</apex:page>
and a apex class
CommunityURL__c communityURL = CommunityURL__c.getValues('CommunityURL');
if (communityURL!=null) {
retURL = new PageReference(communityURL.CommunityURL__c);
retURL.getHeaders().put('Authorization', 'Bearer ' + UserInfo.getSessionId() );
retURL.setRedirect(true);
}
I have the same concern also with a community page. Did anyone found the solution or at least confirm this is a limitation because it's a community page?
Thanks :)
this is new:
https://www.salesforce.com/blog/2019/01/introducing-mobile-publisher-community-cloud.html
so see this :
use the frontdoor url and call VF Page which redirect to SFDC Commnunity
an VF page
<apex:page controller="xxx " action="{!redirect}">
</apex:page>
and a apex class
CommunityURL__c communityURL = CommunityURL__c.getValues('CommunityURL');
if (communityURL!=null) {
retURL = new PageReference(communityURL.CommunityURL__c);
retURL.getHeaders().put('Authorization', 'Bearer ' + UserInfo.getSessionId() );
retURL.setRedirect(true);
}
Actually, I set the session ID this way to the header but I am still prompted to login:
this.state.url is the community URL
this.state.token is a valid token of course.
Basically, I do have a parent app built with Swift on top of the salesforce mobile sdk. I created a child app with react native with a webview to login as a community user and I expect to pass the token from the parent app to the child and then to the webview but everything works fine except this part. Not sure to understand the link with the frontdoor page, to be honest.
Thanks