.net - Gmail API returns 403 forbidden and no other messages (other API's working fine) -


I found an application with many successful Google API integration. I'm trying to add Gmail integration to the mix. I am using the .NET API, Google.Apis.Gmail.v1 (version 1.9.0.140)

Here my code is showing a successful Drive API call, after which the Gmail API call fails:

var drive = new DriveService (reference. GoogleOAuthInitializer); Var list = drive.Files.List (). carry about (); Console.WriteLine (list.Items.Count); // Output: 100 (first page of result) var gmail = new GmailService (context.GoogleOAuthInitializer); Var result = gmail.uppress. Draft.list ("me"). carry about (); //

The exceptions described below provide this information:

  Google.Apis.Requests.RequestError Forbidden [403] Errors [Message [Forbidden] ] Location [-] Reason [forbidden] domain [global]]  

I am using the following scope to get an OOTH token. When I added a Gmail scope, As expected) Google was again indicated, "Do you want to give this application access to your email May include? " I have also enabled Gmail APIs in the Google API console.

  https://www.google.com/m8/feeds https://www.googleapis.com/auth/drive https: //www.googleapis.com/auth/cloudprint https : //www.googleapis.com/auth/userinfo.email https://mail.google.com/ * https://www.googleapis.com/auth/gmail .compose was tried as well < / Code> 

Really desire is something useful in the message, point me in the right direction !!! I started my own out implementation, and I had this code to add authority header:

  void IConfigurableHttpClientInitializer.Initialize (ConfigurableHttpClient httpClient) {string auth = string.format ("AuthSub token = \" {0} \ "", GoogleOAuthToken); HttpClient.DefaultRequestHeaders.Add ("authorization", auth); }  

And this works fine for Drive, Cloud Print and Contacts API, but for some reasons Gmail API is required:

  Zero ICONFigable HTTTP Client Injector Start (configurable http client http client) {string auth = string.format ("Barrier {0}", GoogleOAuthToken); HttpClient.DefaultRequestHeaders.Add ("authorization", auth); }  

I understand, I think, although I do not know why the API will work differently.

Edit: AuthSub is deprecated for Google API:


Comments