Indeed authorization api returns invalid grant

I’ve been using the documentation of Indeed at https://opensource.indeedeng.io/api-documentation/docs/campaigns/auth/ to create campaigns.

curl -X POST 
  -H "Content-Type: application/x-www-form-urlencoded" 
  -H "Accept: application/json" 
  "https://secure.indeed.com/oauth/tokens?code=MY_SECRET_CODE&client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&redirect_uri=MY_REDIRECT_URI&grant_type=authorization_code"

And it returns:

{"error_description":"Invalid grant","error":"invalid_grant"}

I tried to contact Indeed but nobody ansewered me.

Any solution?

Answer

One reason might be a misfit in the Redirect URL which is configured in your Indeed App vs. your Request for the Authorization Code.

Example:

  • In the App/API Keys you configured https://myapp.test.com/oauth (check https://secure.indeed.com/account/apikeys)

  • In the OAuth request url you had a slight different redirect url: https://secure.indeed.com/account/oauth?client_id= MY_CLIENT_ID&redirect_uri=http%3A%2F%2Fwww.somethingElse.com%2Foauth&response_type=code

Matching them exactly resolved the issue for me and it worked nicely.

Leave a Reply

Your email address will not be published. Required fields are marked *