我的代码如下。 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}}