7 votes
Accepted

Error: INVALID_SESSION_ID: Session expired or invalid when Deploy on Visual Studio Code

I ran into this issue after I had to change my password in the sandbox. I just ran this command to fix it: sfdx force:auth:web:login -a <alias> -d -r https://test.salesforce.com This will open ...
user avatar
  • 146
5 votes
Accepted

UserInfo.getSessionID() or connected app with consumer key and secret for a rest resource within a same org

UserInfo.getSessionId() now works in asynchronous code as of Winter '19. The sandbox that it's currently failing in is most likely in Summer '18. Once your sandbox is upgraded, it should work as ...
user avatar
  • 438k
5 votes
Accepted

Trying to get session id in a batch/queueable apex

First, you can't debug the session ID, because it is protected from being debugged on purpose as a security restriction. If you're seeing that message, that means you have a valid session Id. Second, ...
user avatar
  • 438k
5 votes

Error: INVALID_SESSION_ID: Session expired or invalid when Deploy on Visual Studio Code

I solved it through the following steps- At the bottom left of your VS Code you will find a small box icon to 'open the org'. Just click on that. Wait till the operation finishes. Then try to deploy ...
user avatar
4 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 ...
user avatar
  • 438k
4 votes
Accepted

Allow Session ID to persist after release

I would recommend using the JWT flow for this use case, not the username-password flow. There is a nice guide to doing headless JWT authentication in the Salesforce DX Developer Guide. You don't have ...
user avatar
  • 87.3k
3 votes
Accepted

Unable to aquire valid session id using an apex class

From this Article I was able to extract this method here: First create a VisualForce page with the name: currentUserInfoCtrl and then insert into it: <apex:page > Start_Of_Session_Id{!$Api....
user avatar
3 votes

"Session expired or invalid","errorCode":"INVALID_SESSION_ID" while making REST call via cURL

Escaping the Session ID or Using Single Quotes on Mac and Linux Systems When running the cURL examples for the REST resources, you may get an error on Mac and Linux systems due to the presence of the ...
user avatar
  • 4,769
3 votes
Accepted

SOAP method of authentication

Yes, you can use a Session Id for all APIs that you have permission to use. For example, you can use the Metadata API only if you have administrative permissions. The Session Id may be used for any of ...
user avatar
  • 438k
2 votes
Accepted

Can I re-use a session ID outside of Salesforce?

In theory, you can. In practice, you should not. The ideal situation would be to use the appropriate API to get your own, separate session. You can use the Canvas API to get a session in a frame ...
user avatar
  • 438k
2 votes

Possible to make API GET calls directly with the browser?

The endpoint you are referencing is part of the Reports and Dashboards REST API. You need to include an authentication token as a Header in your GET request. Details on how to authenticate via OAuth 2....
user avatar
2 votes

Unable to aquire valid session id using an apex class

The sessionId obtained from auraEnabled cannot be used to make metadata api calls or the tooling api callouts . Here are couple of techniques that you can use Set up Named Credential and Auth ...
user avatar
2 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 ...
user avatar
  • 87.3k
2 votes

can we authorize vscode using session id? because i am not able to authorize , it gives error that no event found

A command was recently added to the Salesforce Extension pack to authorize an org using a session ID. Look for 'SFDX: Authorize an Org using Session ID' from the command palette.
user avatar
2 votes
Accepted

SessionId in LWC for Security Review

No, this would not pass the Security Review, and is inappropriate for a managed package, which should not steal the authentication data of its users. If you want to act on behalf of a user, don't ...
user avatar
2 votes

SFDX: How to log in by session id and session url

You might have better luck here using the jsForce library, which is what sfdx uses under the hood, I believe. This page should show you how to create a new connection using jsForce with a session Id ...
user avatar
  • 176
1 vote
Accepted

SFDX: How to log in by session id and session url

As per SFDX Dev Guide you need to set instanceUrl in config and after that you can use access token in place of username. But for this you need to set instanceUrl either globally or in SFDX project (...
user avatar
  • 148
1 vote
Accepted

Track Mobile Sessions Using Marketing Cloud SDK

Last Application Open and Last Message Open are part of the Mobile Push data model. You can check the list of all available attributes by going to Data Designer > Mobile Push Data. From the send ...
user avatar
  • 1,036
1 vote
Accepted

How to get session id of a particular user in Salesforce

We do not have any credentials of the user to get the session id of that user by logging in If that’s the case, then you cannot call any APIs. That’s not how APIs or any other services work. If you ...
user avatar
  • 29.2k
1 vote

Unable to aquire valid session id using an apex class

I followed the steps mentioned here - https://www.gscloudsolutions.com/blogpost/Using-Named-Credentials-with-the-Apex-Wrapper-Salesforce-Metadata-API-apex-mdapi?blogpost=true and It worked for me. ...
user avatar
1 vote

How to Redirect to /secur/logout.jsp from @Invocable method

Just get the SessionId of the User and redirect them to the revokeURL, it will log out from the browser. public PageReference logout(){ HttpRequest hreq = new HttpRequest(); ...
user avatar
1 vote
Accepted

Session API validity

For both of your questions the answer is Yes. But the time frame is maintained under the Session Settings in Setup. As per docs: The session timeout for an access token can be configured in ...
user avatar
1 vote

"Session expired or invalid","errorCode":"INVALID_SESSION_ID" while making REST call via cURL

I was able to resolve the issue with the following: 1) My instance was wrong. So, I replaced eu11 with na11 which was correct 2) I did not escape !. I just gave my access token in the curl command ...
user avatar
1 vote
Accepted

Session Id from Developer console and session Id from SOAPUI

There are different "classes" of session that get provided in different contexts. You get different types of Session primarily as a security control. Some can only be used to make API calls, some can'...
user avatar

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