【问题标题】:Google.Apis.Auth.1.8.1 Sample for authentication (WP8, WP8.1 & Windows Store Apps)Google.Apis.Auth.1.8.1 身份验证示例(WP8、WP8.1 和 Windows 应用商店应用)
【发布时间】:2014-05-04 21:58:08
【问题描述】:

我正在尝试使用 nuget 包 Google.Apis.Auth.1.8.1 在 Windows Phone 和 Windows Store 应用程序中进行身份验证。

我发现了这个 Google C# Api Beta 1.6 Authentication Issue 和这个 https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth 但我不想使用 CalendarService...

我的问题是:

  1. 哪个是最适合我的样本 - 我只想进行身份验证?是这个吗(注意:这是针对 Windows 应用商店的应用)

    var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
        new Uri("ms-appx:///Assets/client_secrets.json"),
        null,
        "user",
        CancellationToken.None
    );
    
  2. client_secrets.json 的格式是什么?是这个吗

    {
      "clientid ": "the client id here",
      "clientsecret ": "the client secret here",
    }
    

【问题讨论】:

    标签: authentication windows-phone-8 windows-store-apps google-api-dotnet-client


    【解决方案1】:

    CalendarService 只是 Google API 服务的一个示例(任何 Google 服务,例如 YouTubeService、DriveService 都适合您)。

    你想做什么?如果您想使用 Google 服务,您应该从http://www.nuget.org/packages?q=google.apis 下载正确的服务。

    如果您只想进行身份验证,请使用您刚才提到的 AuthorizeAsync 方法。 Windows Store App 身份验证在此处描述:https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#windows8

    在此处阅读有关客户端机密以及如何下载它们的更多信息:https://developers.google.com/accounts/docs/OAuth2#basicsteps

    祝你好运!

    【讨论】:

    • 我只想创建一个带有使用谷歌身份验证的按钮的应用程序,对我来说使用日历或驱动器等服务没有意义,因为我不需要它,我不会使用它。只需要认证... AuthorizeAsync 方法的作用域可以为null吗?
    • 我想你会想要使用以下范围“googleapis.com/auth/userinfo.email”。
    • 我找到了我的解决方案:_credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = Constants.GoogleClientId, ClientSecret = Constants.GoogleClientSecret }, new[] { Oauth2Service.Scope.UserinfoEmail, Oauth2Service.Scope。 UserinfoProfile }, "user", CancellationToken.None);
    猜你喜欢
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多