1

I'm using Named Credentials to support a Scheduled Apex job that needs to call into the Salesforce REST API. The Named Credential is of type Named Principal, using Oauth, and it works just fine.

Here's my question: is there any way for my Apex code to determine whether this credential currently has a valid authentication status and, if not, prompt the user to authenticate? I'm wondering about the deployment process for this application to my production instance - do I need to manually authorize the named credential as part of my deployment process, or can I account for this in code?

0

Since your environment changed when you move to production, you need to do a manual step to authorize the user used for the integration. With Named credential, after you deploy it , use the Start Authentication Flow on Save option to authorize the user. enter image description here

As for Oauth you would be using access token for the integration. Reading this might be helpful - OAuth Access Token Expiration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.