7

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 up your browser to login to the sandbox. I was able to deploy to the org after doing this. (The -r lets you login to a sandbox. Without it, your browser will ...


5

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, this "hack" is no longer necessary. In API version 44.0 and higher, UserInfo.getSessionId() now works in asynchronous code.


4

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 to use SFDX to do this; there are JWT libraries available for many languages. The benefit of using JWT is that your application can always obtain a new token (...


4

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 expected. API calls sometimes require a session ID and a URL. You can obtain that session ID using the System.UserInfo.getSessionId() method. This method ...


3

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 the REST, Bulk, SOAP, Metadata, Streaming, Chatter, or other APIs I haven't mentioned here. There's no real "drawback", except that with a Session Id, you do ...


3

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 exclamation mark special character in the session ID argument. To avoid getting this error, do one of the following: Escape the exclamation mark (!) special ...


3

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 again.


2

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 and server url


2

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.0 here: User Agent OAuth flow. As the commenters mentioned, the two most user friendly ways to access this endpoint is via: Workbench > Utilities > REST ...


2

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.Session_ID}End_Of_Session_Id </apex:page> Then create a new Apex class that will reference the Apex Page @AuraEnabled public static String ...


2

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 code from making API calls to Salesforce. Using a named credential for specific API calls allows you to carefully and selectively bypass this security ...


2

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 inside Salesforce, or you can use the OAuth 2.0 Web Server flow. Both methods can be configured for full, seamless integration, no login required. Keep in mind that ...


1

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 (one sfdx project for each different instanceUrl)


1

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 reports, you can also have Time in App when a Push notification is opened. But if you are looking for more detailed session data, I would suggest that you extend ...


1

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 want to invoke an API, you will need to utilize a User credential here. Remember to be able to call a REST API, you will need an auth token. And if you cannot ...


1

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. One modification - While creating connected app, in "Selected OAuth Scopes" select all the options shown in the image here -


1

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 Provider to obtain sessionId . This is documented in the blog here or 2.Use a proxy visualforce to obtain the SessionId using the global variable .It is documented ...


1

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(); String token = UserInfo.getSessionId(); hreq.setEndpoint('https://login.salesforce.com/services/oauth2/revoke?token=' + token); hreq.setMethod('...


1

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 Salesforce from Setup by entering Session Settings in the Quick Find box, then selecting Session Settings. In Session Setting you can maintain all the ...


1

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't make API calls, while others give you the full level of control that the user has. The Session Types are accessible under "User Session Information" in the ...


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