Hot answers tagged

37 votes
Accepted

Getting Session ID in Lightning

So, as it turns outs there is no way of getting a valid API-capable Session Id from lightning component, here is a quote from the partner discussion forums: Three things: There's no $Api global ...
Jose's user avatar
  • 2,102
11 votes

Getting Session ID in Lightning

There is a Salesforce-accepted way to do this. Use a Named Credential along with a Connected App and Auth Provider (which will be Salesforce). The Named Credential will be used as your endpoint ...
womanwhodevs's user avatar
9 votes
Accepted

Session Id not getting refreshed automatically with Custom Auth provider in Salesforce Named Credentials

Just an update for anyone facing the same issue. After raising a case with SF we could confirm that the refresh function is only triggered to get new session Id in case the previous callout return '...
Abhijeet Bhandari's user avatar
9 votes
Accepted

Can API access be limited to only via Apex classes?

In Winter '18, they added an ability to control access to Apex REST Services that is distinct from the API Enabled permission on profiles that provides access to the standard APIs. This allows you to ...
Kris Goncalves's user avatar
7 votes

Getting Session ID in Lightning

According to the known issue Summer'17- Generating a Session Id from Lightning Domain Provides Invalid Session Id (W-3981698) it should be possible to pass UserInfo.getSessionId() out to lightning ...
Daniel Ballinger's user avatar
7 votes
Accepted

Can we use the use frontdoor link to redirect to a salesforce record directly by passing parameters?

It works pretty much as you've suggested. Send the users browser to: https://eu5.salesforce.com/secur/frontdoor.jsp?sid=sessionId&retURL=%2F0032400000GRVvYAAX Remember to URL encode the ...
Daniel Ballinger's user avatar
7 votes

Determine whether running user is logged in from within Trusted IP Range (from Apex)

You can accomplish this with Auth.SessionManagement class methods. The code below sets the isTrustedIp variable based on whether or not the running user's IP address is in the trusted ranges (as ...
Brent Bowers's user avatar
  • 3,074
6 votes
Accepted

Sandbox session gets confused across browser tabs

Use an incognito window or a different browser. You should only experience this issue if both orgs are on the same instance, e.g. cs12.
Adrian Larson's user avatar
  • 149k
5 votes

Session expiry in Salesforce - Session timeout value for Connected Apps

If you read properly in the link you have provided, The expires_in attribute is given on the call back URL and not as web service response. Even if you get expires_in there is still a catch. The ...
Pranay Jaiswal's user avatar
5 votes

Sandbox session gets confused across browser tabs

Set up My Domain in your production org, then refresh your sandboxes. They'll each get unique domains, and will allow you to work seamlessly in multiple orgs. The URL for each sandbox will change to ...
sfdcfox's user avatar
  • 481k
5 votes
Accepted

Why values does not match for GETSESSIONID and getSessionId?

Salesforce has multiple domains, such as visual.force.com, lightning.com, org.my.salesforce.com, etc. When you log in, a parent session is created; depending on how you log in, you'll get a different ...
sfdcfox's user avatar
  • 481k
4 votes
Accepted

The page you submitted was invalid for your session

The problem is with this line here param.putAll(ApexPages.currentPage().getParameters()); and in particular with the save_new parameter that is being added to the URL causing the error. Similar issue ...
Jenny B's user avatar
  • 10.5k
4 votes
Accepted

Do access token expiration times reset/get updated every time they are used?

"Access Tokens", as well as "SOAP Session Identifiers" ("sid" for short, in most cases) are all treated the same. They are sessions that have an expiration date. You can ...
sfdcfox's user avatar
  • 481k
4 votes

How to test XSS/Content Sniffing protection in sandbox?

According to Platform Security FAQS. X-Content-Type-Options: no sniff The HTTP header can be turned on or off by each organization under Setup > Security Controls > Session Settings > ...
Daniel Ballinger's user avatar
4 votes
Accepted

Lock sessions to the IP address from which they originated

According to the definition Lock sessions to the IP address from which they originated Determines whether user sessions are locked to the IP address from which the user logged in, helping to ...
Santanu Boral's user avatar
4 votes

Is session duration guaranteed?

Separating your questions. My question is however, is this value of 2 hours guaranteed as a minimum session length? Will it always be at least 2 hours? Yes and No (No if a User ends the ...
Jayant Das's user avatar
  • 30.3k
4 votes
Accepted

How to get remaining session time in Apex for current user

I know we can configure session timeout, but how can we get the configured session timeout value in Apex code? String sessionLength = Auth.SessionManagement.getCurrentSession().get('NumSecondsValid');...
sfdcfox's user avatar
  • 481k
4 votes

How to get remaining session time in Apex for current user

If you happen across the documentation on the AuthSession object, you'll get a helpful hint (emphasis mine): LastModifiedDate Type dateTime Properties Defaulted on create, Filter, ...
Adrian Larson's user avatar
  • 149k
3 votes

session id or oath token, they not interchangeable?

Session Id values and Authorization tokens are indeed interchangeable. In fact, I often use Session Id values instead of a token when I'm mocking a quick JavaScript function in my browser. For example:...
sfdcfox's user avatar
  • 481k
3 votes
Accepted

Login History, User Session and User Activity reports in custom visualforce page leading to chart.js dashboards

I have access LoginHistory (key prefix 0Ya) via a SOQL query. Make sure you are using API version 21.0 or higher to see it. You could test this from the developer console SOQL tool or anonymous Apex. ...
Daniel Ballinger's user avatar
3 votes

Is it possible to set a session time out for a specific user?

I don't think it is possible. Meanwhile you can upvote this idea Session Timeout settings for a specific user.
Tushar Sharma's user avatar
3 votes
Accepted

How to poll data without resetting the session clock

Any activity on a session ID resets the timer. This includes polling, streaming, or generally doing anything at all that interacts with the user. Worse, implementing your own time out method in your ...
sfdcfox's user avatar
  • 481k
3 votes

Salesforce logout hook

It's 2019... Now salesforce has provided ability to capture the logout event by releasing an object LogoutEventStream as a beta feature. After LogoutEventStream is enabled, Salesforce publishes ...
Ayub's user avatar
  • 3,443
3 votes
Accepted

Is there a unique session ID for a primary tab in Service Console?

The tab IDs are unique within a console, but not guaranteed to be the same if you close and reopen a tab or if you leave and re-enter the console. So you may have primary 'scc-pt-0' with a subtab '...
Paul H.'s user avatar
  • 1,338
3 votes

How can I find the AuthSession that corresponds with the current Session Id?

This is now partially possible using AuthSession.IsCurrent: If true, the session is a member of the user’s current session family. This was introduced in Summer'16 (v37.0).
Daniel Ballinger's user avatar
3 votes
Accepted

Session Settings

They have different meanings. From this doc: Lock sessions to the IP address from which they originated Determines whether user sessions are locked to the IP address from which the user logged in, ...
Sebastian Kessel's user avatar
3 votes

How can we ensure sessions time out?

Session time outs only occur when the user doesn't do anything for the specified time window. If a user is "happily working" in salesforce, they're doing something, and so they won't be timed out. If ...
sfdcfox's user avatar
  • 481k
3 votes

How to Make Session Expire with Salesforce Connected App Web Server Flow

Session Timeout Org defaults is overrrided by Profile's Session Timeout Value. Make sure that's also 15 mins. You can control session settings on a user profile basis. If you don’t configure the ...
Pranay Jaiswal's user avatar
3 votes
Accepted

INVALID_SESSION_ID when calling Salesforce services from Java

This is a pretty common problem. After you call the login method you get a LoginResult back in the response. That response includes the sessionId that you then need to include in the in the ...
Daniel Ballinger's user avatar
3 votes
Accepted

System.UserInfo.getSessionId() and metadata API

Lightning Components' Apex controllers do not receive an API-enabled session: By security policy, sessions created by Lightning components aren’t enabled for API access. This prevents even your Apex ...
David Reed's user avatar
  • 92.1k

Only top scored, non community-wiki answers of a minimum length are eligible