How to create label in Gmail

Typically, the reason for an exception will be apparent in the first couple of lines.
In this case, it shows the reason as “access_denied” which means your authentication isn’t working properly.
This could be either because your user credentials are wrong or there may be some settings not configured from the Gmail API which is supposed to respond to the request.