1

Google APIを使用して電子メールを読み取ろうとしていますが、繰り返し結果が得られません。それはバックグラウンドで定期的に実行されるサーバー - >サーバーアカウントであるはずですが、接続することはできません。コードは基本的なものです:Google API(Gmail)が失敗した前提条件で失敗しました。

 GoogleCredential credential; 
     using (var stream = new FileStream("Content/service_credential.json", FileMode.Open, FileAccess.Read)) 
     { 
      credential = GoogleCredential.FromStream(stream); 
      credential = credential.CreateScoped(new[] { GmailService.Scope.GmailModify }); 
     } 

     var service = new GmailService(new BaseClientService.Initializer() 
     { 
      HttpClientInitializer = credential, 
      ApplicationName = "try-apis", 
     }); 


     ListLabelsResponse response = service.Users.Labels.List("me").Execute(); 
     foreach (Label label in response.Labels.OrderBy(p => p.Name)) 
     { 
      Console.WriteLine(label.Id + " - " + label.Name); 
     } 

     Console.Read(); 

エラー:IAM設定で

Additional information: Google.Apis.Requests.RequestError 

Bad Request [400] 

Errors [ 

    Message[Bad Request] Location[ - ] Reason[failedPrecondition] Domain[global] 

] 

、私が使用しているアカウントが完全な権限を持っています enter image description here

アカウントが完全な権限を持っています enter image description here

同様に、より完全なアクセス許可: enter image description here

私には何が欠けていますか?ボックスに接続するだけで意味のある代表的な.Net要求を見つけることはできません。

おかげで、 ジェームズ

+0

このことから基づいて、[ブログ](http://techathlon.com/fix-bad-request-error-400-gmail-google-chrome/)、Chromeを使用してGmail用に複数のGoogleアカウントにログインしている場合、不正リクエストエラー400が発生した可能性があります。この[あなたの質問](http://stackoverflow.com/questions/32591549/gmail-api-400-bad-request-when-trying-to-send-an-email-php-code)から、おそらく問題がある認証と一緒に。関連リンクを確認してください:http://stackoverflow.com/questions/29327846/gmail-rest-api-400-bad-request-failed-precondition – abielita

答えて

0

私は前にドメイン全体の委任を付与するIAM方法を見たことがありません。

これらのドキュメントに記述のように一般的に開発者のIDがドメインCPanelの中​​にホワイトリストに登録されています(「後のGoogle Appsドメインの管理者は、次の手順を完了する必要があります」と言う段落)https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority

関連する問題