How to check if current connect is still valid or expired?
See original GitHub issueHi,
I’m using JSforce Node.js package to interact with salesforce?
Is there anyway to check if current connected session is still valid or expired?
var connection = new jsforce.Connection({
loginUrl : LOGINURL
});
connection.login(USERNAME, PASSWORD + TOKEN, (err: any, res: any) => {
if (err) {
console.log('Connection Completed With Error: ', err);
}
console.log('Connection Token: ' + connection.accessToken);
console.log('Connection instanceUrl: ' + connection.instanceUrl);
});
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:8
Top Results From Across the Web
How To Check SSL Certificates and Stay Secure - Keyfactor
Click on the certificate pop-up and check the certificate details such as expiry date and the valid duration.
Read more >Javascript Check if the Date is already Expired in Token
To check if a given JWT is expired then you can just compare against the current date as a UNIX timestamp: var decodedToken...
Read more >How To Check SSL Certificates [SSL Validation] - Venafi
Click on Certificate (Valid) in the pop-up; Check the Valid from dates to validate the SSL certificate is current. The displayed information includes...
Read more >How to Check a Certificate's Expiration Date (Chrome)
How to Check a Certificate's Expiration Date (Chrome) ; 1. Click the padlock · Click the Padlock ; 2. Click on Valid ·...
Read more >How to check TLS/SSL certificate expiration date from Linux CLI
Explains how to check the TLS/SSL certificate expiration date from Linux or Unix CLI and send an email alert using a simple script....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@johnoliv - that is surprising, but makes sense.
even without the issue you are having, logging in with username and password should be avoided if possible.
But if that is the best way for your use-case, you should still be able to use oauth2 using the username+password flow as documented here: https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_username_password_flow.htm&type=5 which should work with identity and can use the native token refresh flow while still using username and password.
Note: I am not 100% sure if jsforce supports this login flow natively, but you can make the request yourself to get the token, then initialize jsforce with the oauth2 data. I have a vague memory that I tried it once and jsforce did not work.
You need to create a connected app in your production org or a dev org (any org that does not get deleted)
AFAIK the only way to know if a connection is valid or not is to try out an API call, at which time the token might be refreshed automatically, if possible, or will fail.