You need to sign in to do that
Don't have an account?
Francesco Tisiot
Frontdoor.jsp not working with Auth token
Hi all,
I created a connected app with Full and Web scope included. I'm able to retrieve the salesforce instance and access token and query the salesforce objects with rest apis.
However when I try to access the Frontdoor.jsp with the call https://inst.salesforce.com/secur/frontdoor.jsp?sid=<access_token>&retURL=<ret_url>
I always get the login page.
The same call done by using a session id (taken from a Firefox cookie) works.
In the documentation of frontdoor.jsp is written that an access_token can be passed if the connected abb has full or web scope included, but mine doesn't work... do you have any hint for this?
I created a connected app with Full and Web scope included. I'm able to retrieve the salesforce instance and access token and query the salesforce objects with rest apis.
However when I try to access the Frontdoor.jsp with the call https://inst.salesforce.com/secur/frontdoor.jsp?sid=<access_token>&retURL=<ret_url>
I always get the login page.
The same call done by using a session id (taken from a Firefox cookie) works.
In the documentation of frontdoor.jsp is written that an access_token can be passed if the connected abb has full or web scope included, but mine doesn't work... do you have any hint for this?
The solution : Get an access token via SOAP : https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_login.htm
You can slot the access token id you get from the soap login into your frontdoor.jsp call.
public TokenResponse GetSoapTokenResponse()
{
TokenResponse token = null;
var username = System.Configuration.ConfigurationManager.AppSettings["SF.Username"];
var password = System.Configuration.ConfigurationManager.AppSettings["SF.Password"];
var securitytoken = System.Configuration.ConfigurationManager.AppSettings["SF.SecurityToken"];
SforceService binding = new SforceService();
LoginResult lr = null;
try
{
lr = binding.login(username, password + securitytoken);
token = new TokenResponse();
token.instance_url = lr.serverUrl;
token.access_token = lr.sessionId;
token.id = lr.userId;
}
catch (Exception e)
{
throw (new Exception("Could not authenticate via soap : " + e.Message, e));
}
return token;
}
public string CreateSoapAuthenticatedUrl(string returnUrl)
{
var token = GetSoapTokenResponse();
string baseURL = System.Configuration.ConfigurationManager.AppSettings["SF.FrontdoorUrl"];
// "{0}/secur/frontdoor.jsp?sid={1}&retURL={2}" is what this pulls in.
string instance = token.instance_url.Remove(token.instance_url.IndexOf("/services"));
string url = string.Format(baseURL, instance, token.access_token, Uri.EscapeDataString(returnUrl));
return url;
}
public class TokenResponse
{
public string id { get; set; }
public string issued_at { get; set; }
public string refresh_token { get; set; }
public string instance_url { get; set; }
public string signature { get; set; }
public string access_token { get; set; }
}
<string-array name="oauthScopes">
<item>api</item>
<item>web</item>
</string-array>