13

I have recently implemented a custom auth plugin provider in hopes of getting away from making a token call with every request OR having to manage the token myself.

I am using the Oauth 2.0 client credentials flow.

However, our API gateway is returning a 403 forbidden when the access token expires after one hour.

Unbeknownst to me, the refresh method of the custom auth provider plugin class is ONLY invoked when you receive a 401.

I am looking for a way to still utilize named credentials + auth provider + custom auth provider plugin to manage the tokens, but manually invoke the refresh method if I get a 403. I suppose I could generate a Map<String,String> and simulate the config by querying the metadata, but I'm wondering if there is a more direct way that I am not able to find.

References to 401/403 difference:

https://trailblazer.salesforce.com/ideaView?id=0873A000000CXzjQAG

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Auth_AuthProviderPluginClass.htm

Session Id not getting refreshed automatically with Custom Auth provider in Salesforce Named Credentials

2
  • Did you find a way to fix this?
    – Damecek
    Dec 22, 2022 at 20:56
  • 1
    @Damecek, we were users of Apigee and ended up adding a policy at our mw/gateway to flip the status code.
    – S.B.
    Jan 2, 2023 at 17:46

0

You must log in to answer this question.