我的新項目需要實現OpenAuth。以下是我的代碼。DotNetOpenAuth2與VB.Net錯誤
在GetAuthorization線
scopes.Add(CalendarService.Scopes.Calendar.GetStringValue())
提供了以下錯誤。
重載決策失敗,因爲沒有可訪問...
向GetStringValue是最具體的這些說法。我可以理解,GetStringValue不是在calendarservice.scopes.calendar中找到的方法/參數,但我的問題是爲什麼呢?我從某個網站下載了這個代碼,大多數網站都給出了C#的例子,但幾乎沒有任何網站在VB.Net中顯示任何示例。有人能幫我一下嗎。
Regards
P.S.我正在使用Visual Studio 2008.
Imports System
Imports System.Diagnostics
Imports DotNetOpenAuth.OAuth2
Imports Google.Apis.Authentication.OAuth2
Imports Google.Apis.Authentication.OAuth2.DotNetOpenAuth
Imports Google.Apis.Calendar.v3
Imports Google.Apis.Util
Imports Google.Apis.Calendar.v3.Data
Imports Google.Apis.Tasks.v1
Imports Google.Apis.Tasks.v1.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim provider = New NativeApplicationClient(GoogleAuthenticationServer.Description)
provider.ClientIdentifier = "Client ID Here"
provider.ClientSecret = "Client Secret Here"
Dim auth = New OAuth2Authenticator(Of NativeApplicationClient)(provider, AddressOf GetAuthorization)
Dim service = New CalendarService(auth)
Dim first = service.CalendarList.List.Fetch().Items().First()
Label1.Text = first.Summary
End Sub
Private Function GetAuthorization(ByVal 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())
' Open a modal dialogue for user to paste the authorization code from Browser = authCode
Dim authCode As String = Console.ReadLine()
Return arg.ProcessUserAuthorization(authCode, state)
End Function
End Class
我無法導入'** Google.Apis.Util.Utilities。**'您是否有任何想法可以爲此導入哪個文件? – 2013-02-14 10:19:40