Trying to debug the Salesforce "invalid_grant audience is invalid" error? Here's how to fix it.
TABLE OF CONTENTS
What causes the Salesforce audience is invalid error?
This error happens during the OAuth 2.0 JWT Bearer Flow for authentication on the server when the aud or audience parameter is invalid for the JSON Web Token Claims. Your JSON Claims Set for the JWT should contain the following parameters:
iss
- the OAuth client_id or the Connected App’s nameaud
- the authorization server’s URLsub
- the username of the user (if implementing for an Experience Cloud site)exp
- the expiration time
Resolution for the audience is invalid error
Make sure that the [.inline-code-highlight]aud[.inline-code-highlight] or audience parameter is one of the following:
https://login.salesforce.com
https://test.salesforce.com
https://site.force.com/customers
(if implementing for an Experience Cloud site)