-1

I am trying to use the nuget package Google.Apis.Auth.1.8.1 for authentication in Windows Phone and Windows Store Apps.

I found this Google C# Api Beta 1.6 Authentication Issue and this https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth but I don´t want to use the CalendarService...

My questions are:

  1. Which is the best sample for me - I only want to authenticate? is this (Note: this is for Windows Store apps)

    var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
        new Uri("ms-appx:///Assets/client_secrets.json"),
        null,
        "user",
        CancellationToken.None
    );
    
  2. What is the format of the client_secrets.json? Is it this

    {
      "clientid ": "the client id here",
      "clientsecret ": "the client secret here",
    }
    
Community
  • 1
  • 1
saramgsilva
  • 734
  • 1
  • 7
  • 17

1 Answers1

0

The CalendarService is just an example for Google API service (any Google service, e.g. YouTubeService, DriveService will work for you).

What are you trying to do? If you want to use a Google service, you should download the right one from http://www.nuget.org/packages?q=google.apis.

If you just want to authenticate use the AuthorizeAsync method you just mentioned. Windows Store App auth is described here: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#windows8.

Read more about the client secrets and how to download them here: https://developers.google.com/accounts/docs/OAuth2#basicsteps

Good luck!

peleyal
  • 3,472
  • 1
  • 14
  • 25
  • i only want to create a app with a button that uses the google authentication, for me don´t make sense use services like calendar or drive, because i don´t need it, i will not use it. Only need to authenticate... Can be the scope of the AuthorizeAsync method be null? – saramgsilva May 05 '14 at 13:23
  • I think you will want to use the following scope "https://www.googleapis.com/auth/userinfo.email". – peleyal May 05 '14 at 14:39
  • I find my solution: _credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = Constants.GoogleClientId, ClientSecret = Constants.GoogleClientSecret }, new[] { Oauth2Service.Scope.UserinfoEmail, Oauth2Service.Scope.UserinfoProfile }, "user", CancellationToken.None); – saramgsilva May 17 '14 at 13:03