Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用google calender Api v3 vb.net_Vb.net_Google Calendar Api - Fatal编程技术网

使用google calender Api v3 vb.net

使用google calender Api v3 vb.net,vb.net,google-calendar-api,Vb.net,Google Calendar Api,我被谷歌日历Api版本3的授权卡住了 我试图构建一个应用程序,将数据库的内容提供给谷歌日历 我让这个应用程序完全在GoogleAPI版本2下工作。 不过,我想在版本3中使用一些新功能 不幸的是,版本3是向后不兼容的 这是我目前的代码: Imports DotNetOpenAuth.OAuth2 Imports Google.Apis.Authentication.OAuth2 Imports Google.Apis.Authentication.OAuth2.DotNetOpenAuth Im

我被谷歌日历Api版本3的授权卡住了

我试图构建一个应用程序,将数据库的内容提供给谷歌日历

我让这个应用程序完全在GoogleAPI版本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
导入DotNetOpenAuth.OAuth2
导入Google.api.Authentication.OAuth2
导入Google.api.Authentication.OAuth2.DotNetOpenAuth
导入Google.api.Calendar.v3
导入Google.api.Calendar.v3.Data
导入Google.api.Util
公共共享Sub-Main(参数为字符串())
Dim provider=新的本地应用程序客户端(GoogleAuthenticationServer.Description)
provider.ClientIdentifier=“”
provider.ClientSecret=“”
Dim auth=新的OAuth2Authenticator(NativeApplicationClient的)(提供程序,GetAuthorization的地址)
Dim服务=新日历服务(认证)
端接头
私有共享函数GetAuthorization(arg作为NativeApplicationClient)作为IAAuthorizationState
Dim作用域作为新的System.Collections.Generic.List(字符串)
添加(CalendarService.scopes.Calendar.GetStringValue())
作为IAAuthorizationState的Dim状态=新授权状态(作用域)
state.Callback=新Uri(NativeApplicationClient.OutOfBandCallbackUrl)
Dim authUri作为Uri=arg.RequestUserAuthorization(状态)
Process.Start(authUri.ToString())
返回参数ProcessUserAuthorization(状态)
端函数
我犯了一个错误; 错误1“IAAuthorizationState”在命名空间“DotNetOpenAuth.OAuth2”中不明确

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

希望有人能帮助我


提前感谢您的努力!:)

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

然而,我没能让Google Calender Api v3正常工作,所以我在Api v2中制作了这个应用程序,它的工作方式很有魅力!:)


不过,我还是觉得谷歌很奇怪,带OAuth2的v3在VB.Net中无法正常工作

错误是告诉您有两种类型,它们都称为
IAuthorizationState
。如果您需要为这两种类型导入名称空间(听起来像是这样),那么您需要完全限定该类型名称。嗨,David,谢谢您的快速回复。除了
DotNetOpenAuth.OAuth2
之外,我找不到包含
iaauthorizationstate
的其他DLL。在编译过程中,该库是否以某种方式加载了两次?也许项目文件中有错误?如果删除
DotNetOpenAuth.OAuth2
Imports
指令(并完全限定使用该指令的任何内容),会发生什么情况?如果我对
'import DotNetOpenAuth.OAuth2
进行注释,然后键入
'Private Shared Function GetAuthorization(arg As NativeApplicationClient)会很奇怪作为DotNetOpenAuth.OAuth2.IAuthorizationState'
DLL不会重新编码命令。解决了这个问题,我通过NuGet导入了DLL,它似乎安装了
DotNetOpenAuth.OAuth2和DotNetOpenAuth.OAuth2.client
,但是我得到的最后一个编译错误是:
类型为'Google.api.Authentication.OAuth2.OAuth2Authenticator的错误1值(属于Google.api.Authentication.OAuth2.DotNetOpenAuth.NativeApplicationClient)'无法转换为'Google.api.Services.BaseClientService.Initializer'。
我猜我使用了一个错误的DLL,但是我从谷歌网站上获得了该DLL,并且找不到它的其他较新版本。