function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mateusz Wolak-Książek 17Mateusz Wolak-Książek 17 

Access Token not refreshing - Named Credentials & Auth Provider


I have following problem - I'm using named credentials with auth provider to send offline conversion to Google Ads.


My auth provider setup:

Provider Type - Open ID Connect
Name - Google API
URL Suffix - Google_API
Consumer Key - ***
Authorize Endpoint URL -
Token Endpoint URL -
Default Scopes - openid 


My named credential setup:

Url -

Scope - openid
Generate Authorization Header - checked


My app at google contains redirect_uri from salesforce and in "APIs & Services" I have enabled "Google Ads API".


When I edit named credential and "Start Authentication Flow on Save" and enter my google credentials, my integration works for 1 hour. I receive 200 and can see that Google Adwords received my data.

After na hour I receive;

"System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: [AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'<null>'] faultcode=soap:Client faultactor="


When I reauthenticate in named credentials once again it start to again work for another hour.

Have you got guys any ideas what I'm doing wrong?

bharath kumar 52bharath kumar 52

Can you try using a refresh token?
I am sure there's a way to generate a refresh token using google's connected app since the auth provider is google. Let me know if thhis helps.

Mateusz Wolak-Książek 17Mateusz Wolak-Książek 17


I could, but I don't really know how to get refresh token using named credentials and auth provider? Is it even possible? And even when I would have it, how would I use it in SOAP integration using named credentials & auth provider?

We have similar integration with google analytics and everything works well, but there is another named credential with different endpoint and scope - there is scope - openid



Mateusz Wolak-Książek 17Mateusz Wolak-Książek 17

Oh, and I have tried also this - but my dummy request does not even work - no matter how many times I try to invoke integration after an hour from authentication - all the times it returns

NAMED_CREDENTIAL_RESPONSE|NamedCallout[Name=Google_AdWords, Status Code=500]
EXCEPTION_THROWN|[333]|System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: [AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'<null>'] faultcode=soap:Client faultactor=


Mateusz Wolak-Książek 17Mateusz Wolak-Książek 17
any idea guys? :(
Pamidimukkala PhanikanthPamidimukkala Phanikanth
Hi Mateusz,

Have you got the solution for your query. In my application also i am facing the same issue. If you found issue, please let us know where we are doing mistake.

Thanks and Regards,
Phanikanth P