0

我卡在 Google Calendar Api version3 的授权上

我正在尝试构建的是一个将数据库内容提供给 Google 日历的应用程序

我让这个应用程序在 Google Api 版本 2 下完全运行。但是我想使用版本 3 中的一些新功能。

不幸的是,版本 3 向后不兼容

到目前为止,这是我的代码:

Imports DotNetOpenAuth.OAuth2

Imports Google.Apis.Authentication.OAuth2
Imports Google.Apis.Authentication.OAuth2.DotNetOpenAuth
Imports Google.Apis.Calendar.v3
Imports Google.Apis.Calendar.v3.Data
Imports Google.Apis.Util

Public Shared Sub Main(args As String())

    Dim provider = New NativeApplicationClient(GoogleAuthenticationServer.Description)
    provider.ClientIdentifier = "<client id>"
    provider.ClientSecret = "<client secret>"
    Dim auth = New OAuth2Authenticator(Of NativeApplicationClient)(provider, AddressOf GetAuthorization)

    Dim service = New CalendarService(auth)

End Sub

Private Shared Function GetAuthorization(arg As NativeApplicationClient) As IAuthorizationState

    Dim scopes As New System.Collections.Generic.List(Of String)

    scopes.Add(CalendarService.Scopes.Calendar.GetStringValue())

    Dim state As IAuthorizationState = New AuthorizationState(scopes)
    state.Callback = New Uri(NativeApplicationClient.OutOfBandCallbackUrl)
    Dim authUri As Uri = arg.RequestUserAuthorization(state)

    Process.Start(authUri.ToString())

    Return arg.ProcessUserAuthorization(state)

End Function

我收到一个错误;Error1“IAuthorizationState”在命名空间“DotNetOpenAuth.OAuth2”中不明确。

我不知道我做错了什么(我遵循 Google api 手册的每一步,也有所有需要的 DLL)

希望有人可以帮助我。

提前感谢您的努力!:)

4

1 回答 1

0

修复了这个问题,我通过 NuGet 导入了 DLL,似乎它已安装DotNetOpenAuth.OAuth2DotNetOpenAuth.OAuth2.client

但是,我没有设法让 Google Calender Api v3 正常工作,因此在 Api v2 中制作了该应用程序,就像一个魅力!:)

我仍然觉得谷歌很奇怪,带有 OAuth2 的 v3 不能在 VB.Net 上正常工作

于 2013-09-12T07:14:44.410 回答