2015-04-06 76 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