를 사용하여 액세스 토큰을 검색 할 권한이없는 것입니다클라이언트가이 방법의 Gmail API의 C에게 #
"클라이언트가이 방법을 사용하여 액세스 토큰을 검색 할 권한이없는 것입니다"
static async Task MainAsync()
{
sstageEntities db = new sstageEntities();
//UserCredential credential;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
String serviceAccountEmail =
"xxx.iam.gserviceaccount.com";
var certificate = new X509Certificate2(
AppDomain.CurrentDomain.BaseDirectory +
"xxx-8c7a4169631a.p12",
"notasecret",
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
//string userEmail = "[email protected]";
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
User = "[email protected]",
Scopes = new[] { "https://mail.google.com/" }
}.FromCertificate(certificate)
);
// Create Gmail API service.
var gmailService = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
var emailListRequest = gmailService.Users.Messages.List("[email protected]");
emailListRequest.LabelIds = "INBOX";
emailListRequest.IncludeSpamTrash = true;
emailListRequest.Q = "from:[email protected] is:unread";
//Get our emails
var emailListResponse = await emailListRequest.ExecuteAsync();
난 내 콘솔 occurs.Any 도움 정말 감사하겠습니다 다음과 같은 오류가되는 앱 실행하면 서비스 account.But를 만드는 동안 내가 가진 P12 키를 사용하고 있습니다.
미리 감사드립니다.
을 확인 승인하지 않은 수단? https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority – DaImTo
조직의 관리자 만 할 수 있습니까? 나는 단지 직원 일 뿐이다. – Melvin
네, 관리자 만이 할 수있는 일이라고 생각합니다. – DaImTo