我剛剛開始使用c#Google.Apis.Gmail.V1類並使用服務帳戶來閱讀郵箱。C#GMAIL API服務帳戶修改 - unauthorized_client
我的代碼工作正常,當我用下面的代碼片段
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(ServiceAccountEmailAddress)
{
User = "[email protected]",
Scopes = new[] { "https://www.googleapis.com/auth/gmail.readonly" }
}.FromCertificate(certificate));
與該代碼我可以調用成功以下
if (credential.RequestAccessTokenAsync(CancellationToken.None).Result)
{
}
但我需要修改的電子郵件,所以我改變範圍從
https://www.googleapis.com/auth/gmail.readonly
到
https://www.googleapis.com/auth/gmail.modify
我現在要求的訪問令牌
{時得到一個異常 「錯誤:\」 unauthorized_client \ 「描述:\」 在請求授權客戶端還是範圍。 \「,」Uri:\「\」「}
我已經在Google Developers Console中檢查了服務帳戶(* .iam.gserviceaccount.com),並且已嘗試所有權限選項g應該給我的所有者完全訪問所有資源,但沒有快樂。
我想我只是缺少一個簡單的步驟,但我不確定接下來要看的地方。