Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.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
Asp.net 尝试在vb.net中使用Google实现oAuth时出错_Asp.net_Vb.net_Google Oauth - Fatal编程技术网

Asp.net 尝试在vb.net中使用Google实现oAuth时出错

Asp.net 尝试在vb.net中使用Google实现oAuth时出错,asp.net,vb.net,google-oauth,Asp.net,Vb.net,Google Oauth,我正在尝试在vb.net中开发的基于web的应用程序中使用Google实现登录。我将VS2013与Telerik控件一起使用。不幸的是,vb.net没有可用的示例,谷歌自己似乎不愿意为vb.net提供一个示例。我有一个登录按钮,允许用户通过他们现有的谷歌帐户登录到我的应用程序。下面是相同的代码 Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click Dim clientID

我正在尝试在vb.net中开发的基于web的应用程序中使用Google实现登录。我将VS2013与Telerik控件一起使用。不幸的是,vb.net没有可用的示例,谷歌自己似乎不愿意为vb.net提供一个示例。我有一个登录按钮,允许用户通过他们现有的谷歌帐户登录到我的应用程序。下面是相同的代码

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
尽管对所有内容进行了双重检查,但我还是不断收到“重定向uri不匹配”错误。下面是错误的快照。

我已经阅读了很多关于这方面的文档,正如它所建议的,在Google开发者控制台中配置重定向URL是一个错误,但就我所关心的而言,我认为它是正确配置的。这是我的谷歌控制台客户端ID的快照

这是我的请求源的快照。

如果有人知道并愿意分享这个问题,我将不胜感激,因为这真的让我发疯


非常感谢

您可以像下面这样调用身份验证URL,这是我用于
日历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、主用户、重定向URI。哪里
mainUser
是用于身份验证的邮件id,
redirecturi
是我们处理响应的站点/页面的URI。在传递的url和开发人员控制台中必须相同

非常感谢@Poornima。我将研究代码,看看我的问题是否可以由此解决。再次非常感谢。如果它似乎使用充分然后支持我的朋友在代码项目似乎工作,但这不是我要找的。我只需要来自scope Google.api.Plus.v1.PlusService.scope.UserinfoEmail的用户电子邮件id。虽然您的方法适用于日历,而且效果很好,但这种方法需要事先知道用户的电子邮件id。