In a customer org, Api calls are made using a NamedCredential using an OpenIdConnect AuthProvider. I didn't configure this but my own code fails with 401 Unauthorized. When I going to the NamedCredential and trigger the Auth Flow again it works.

I'm an Oauth newbie but I thought after this initial Authorization when the NamedCredential is saved the token is useable for all time.

Is there something configured incorrectly in Salesforce or in the API backend? Any tips and recommendations are welcome.

  • 1
    Did you include refresh_token as a scope for OAuth? The access tokens generally expire after a few hours. The refresh token allows the system to request a fresh access token without prompting the user again. What is refresh token – Aayush K Jul 12 '19 at 15:21
  • Yes the scope is api refresh_token – Robert Sösemann Jul 12 '19 at 15:27
  • 1
    The devil is in the details here, it depends on the config and if the response from the other party has correct codes, etc. – identigral Jul 12 '19 at 16:35

Your Answer

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

Browse other questions tagged or ask your own question.