使用服务帐户-vb.net禁止使用Google通讯录API 403

时间:2017-05-04 13:10:42

标签: vb.net api http-status-code-403

我的代码如下。 Dim _Scopes As New List(Of String) _Scopes.Add("https://www.google.com/m8/feeds") _Scopes.Add("http://www.google.com/m8/feeds/contacts/") _Scopes.Add("https://www.googleapis.com/auth/contacts.readonly") Dim certificate As X509Certificate = New X509Certificate2("c:\sites\key.p12", "notasecret", X509KeyStorageFlags.Exportable) Dim serviceAccountEmail As String = "serviceaccountemailhere" Dim credential As ServiceAccountCredential = New ServiceAccountCredential(New ServiceAccountCredential.Initializer(serviceAccountEmail) With {.User = serviceAccountEmail, .Scopes = _Scopes}.FromCertificate(certificate)) Dim settings As RequestSettings = New RequestSettings("Gmail Contact APP", Await credential.GetAccessTokenForRequestAsync()) Dim cr As New ContactsRequest(settings) For Each ct In cr.GetContacts.Entries Console.Write(ct.ContactEntry.Name) Next 包含令牌。 设置包含一个子语句和应用程序名称,但没有别的。

我不确定它是否正在验证。令牌,令牌秘密,私钥都没什么。

{{1}}

0 个答案:

没有答案