2015-04-06 39 views
-1

我正在嘗試執行使用Google登錄到我在vb.net開發的基於Web的應用程序中。我正在使用帶Telerik控件的VS2013。不幸的是,沒有有用的例子可用於vb.net和谷歌自己似乎不願意把一個爲vb.net。我有一個登錄按鈕,允許用戶通過他們現有的Google帳戶登錄我的應用程序。以下是相同的代碼。嘗試在vb.net中使用Google執行oAuth時出錯

Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click 
    Dim clientID As String = "xxxxxxxxxxxxxxxxx.apps.googleusercontent.com" 
    Dim clientSecret As String = "xxxxxxxxxxxxxxxx" 

    Dim scopes As String() = New String() {Google.Apis.Plus.v1.PlusService.Scope.UserinfoEmail} 

    Dim credential As UserCredential 
    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With {.ClientId = clientID, .ClientSecret = clientSecret}, scopes, "user", CancellationToken.None, New FileDataStore("Drive.Auth.Store")).Result 
End Sub 

儘管雙重檢查了一切,我仍然收到'redirect_uri_mismatch'錯誤。以下是錯誤的快照。 Error while trying to Login

我已經對這個閱讀大量的文件,當它表明,它與重定向URL錯誤在谷歌開發者控制檯配置,但據我的關注,我認爲這是正確的配置。以下是我的Google控制檯客戶端ID的快照。

enter image description here

這裏是我的請求源的快照。 enter image description here

如果有人知道並願意分享這個問題,我將非常感激,因爲這真的讓我發瘋。

非常感謝

回答

0

你可以打電話驗證URL像下面這樣,這是我用Calender API

Dim Uri As String = "https://accounts.google.com/o/oauth2/auth?access_type=offline&response_type=code&client_id=" & clientId & "&redirect_uri=" & redirecturi & "&scope=https://www.googleapis.com/auth/calendar&login_hint=" & mainUser & "&include_granted_scopes=true" 
     Response.Redirect(Uri) 

你必須給予適當的值:

的clientId,mainUser,redirecturi 。 mainUser是用於身份驗證的郵件標識, redirecturi是我們網站/頁面的URI,我們處理響應。並且在傳遞網址和開發者控制檯中必須相同

+0

請問您可以發佈完整的代碼嗎? – 2015-04-06 08:47:12

+1

http://www.codeproject.com/Tips/869770/Handling-events-in-google-calendar-using-google – 2015-04-06 09:24:27

+0

許多感謝@Poornima。我會研究代碼,看看我的問題是否可以從這個問題中解決。很多再次感謝。 – 2015-04-06 09:40:51

相關問題