【问题标题】:Fetching User Info like Name, Email using Google OAuth2使用 Google OAuth2 获取用户信息,例如姓名、电子邮件
【发布时间】:2015-02-22 15:14:25
【问题描述】:

我在我的应用程序中使用 Google 的 .NET SDK,并希望获取用户信息。 我使用以下范围获得了UserCredential 对象。

  new[] { Uri.EscapeUriString("https://www.googleapis.com/auth/userinfo.email"), 
          Uri.EscapeUriString("https://www.googleapis.com/auth/userinfo.profile") }

在此之后,我正在寻找 UserInfoService 来获取用户的姓名和电子邮件,但找不到。 请注意,我只使用 Google 的 SDK,并没有自己处理请求和响应。
我在其他网站上发现了一些示例,但这些示例不使用 Google API,并且正在形成
请求 url,并且需要解析响应 JSON。

有没有一种方法可以让我在不创建请求 url 的情况下获得 UserInfo 并将其留给 Google API 处理?

【问题讨论】:

    标签: c# oauth-2.0 google-api google-oauth google-api-dotnet-client


    【解决方案1】:

    这里之前已经问过: .NET client for the Google People API

    无论如何,你应该使用OAuth 2.0 库,看起来你会对UserInfoResource.GetRequest 感兴趣。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-21
      • 1970-01-01
      • 1970-01-01
      • 2017-07-09
      • 1970-01-01
      • 1970-01-01
      • 2020-05-21
      • 2017-09-24
      相关资源
      最近更新 更多