Contents
When to use an existing access token in Salesforce?
When you authorize into an org using the auth commands, Salesforce CLI takes care of generating and refreshing all tokens, such as the access token. But sometimes you want to run a few CLI commands against an existing org without going through the entire authorization process.
What happens when I request the same access token?
Access Tokens have fixed Life-Time. Until that period has not expires, access token remains the same. During that period if you request access token you will receive the same string but will have reset expiration. It would only happen if Location, Password etc are exactly same as previous request.
Is it possible to extend the expiration time of an access token?
But apparently you have mentioned that it depends on org’s session policy setting. There is another system which calls salesforce api with the JWT token. After generating the JWT access token it is hardcoded in that system’s setting. There is no mechanism through which we can get new access token if it gets expired.
What happens if you don’t use refresh tokens?
If you use refresh tokens, your code should first try the regular API call, and if you get a 4xx result, try using the refresh token to get a new session token, and if that fails, then you’ve been kicked out, and the user needs to re-authenticate to continue. If you don’t use refresh tokens, you can skip the middle step, obviously
Use an Existing Access Token instead of Authorizing When you authorize into an org using the auth commands, Salesforce CLI takes care of generating and refreshing all tokens, such as the access token. But sometimes you want to run a few CLI commands against an existing org without going through the entire authorization process.
Can a CLI command accept an access token?
Almost all CLI commands that have the –targetusername | -u parameter accept an access token. The only exception is force:user:display. To get the instance URL and access token for the org to connect to, run the force:org:display command. See Authorization Information for an Org.