SendGrid API Key not working. "The provided authorization grant is invalid, expired or revoked"

You need to use the API KEY GENERATED

enter image description here

DO NOT USE the API KEY ID

enter image description here

Sendgrid only displays the generated key once when you create it. enter image description here

If you didn't record it somewhere when you created the key you'll need to create a new key and then you'll probably want to delete the old key since it would be useless if you don't know what it is.

FYI: The API key in the screenshot above is already deleted. I deleted it right away so please don't worry about me leaking that key.


This is a late answer and JAVA oriented.. But I simply copied the docs and didn't notice..

SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));

I just put my key in there and didn't see the getEnv. Silly of course.. but when trying to get things to work quickly...


In Sendgrid v3, I had the similar issue when using env variable in Node JS. If I use env variable, I get the above issue. But if I drop the string into the require process, it works.

Doesn't Work:

SENDGRID_API_KEY=SG.XXXXXXXXXXXXXXXXXXX
var sg = require('sendgrid')(process.env.SENDGRID_API_KEY);

Works

var sg = require('sendgrid')('SG.XXXXXXXXXXXXXXXXXXX');

Replace SG.XXXXXXXXXXXXXXXXXXX with API Key Generated (which you can only see once during key generation).

EDIT

Note : Make sure you don't save this to public repository. If you do anyone can use your API Key and also your account will be suspended by Sendgrid team temporarily until you remove it from repository.