2

I am currently developing a C# MVC website which will use Google's calender API and i'm having trouble getting the OAuth 2.0 sorted out.

I am following this stackoverflow question which references the OAuth2LeggedAuthenticator class which doesn't appear in the latest NuGet packages

Install-Package Google.Apis.Calendar.v3 -Pre

Install-Package Google.Apis.Authentication -Pre

This is because Google have moved to the OAuth 2 Authentication schema, so is there any way of doing 2 legged authentication with the latest version of the .net API?

Cheers

Community
  • 1
  • 1
Lawrence Lee
  • 365
  • 3
  • 8

2 Answers2

1

Managed to figure it out, its somewhat a different process to obtaining access to "Service Accounts" aka your own account.

When you create a new Oauth2 client id in the Google console it generates a certificate with a private key which allows your application to access your own account.

So you use the AssertionFlowClient class instead of a NativeApplicationClient as your provider for API access and passing in your certificate as a parameter.

var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate) 

More info and example can be found at the Google Code .net wiki

Google should really update there Google developers guide as its outdated and was a bit of a uphill push to get info on the new .net V3 API...

Lawrence Lee
  • 365
  • 3
  • 8
  • Which part was outdated? What was missing for you? Be aware that in our next release we going to improve significantly the OAuth2 flows. We are going to make it much simpler to use. I'm aware that today it's complicated, and we are working on that. Feel free to open issues in our issue tracker (https://code.google.com/p/google-api-dotnet-client/issues/list) if something is outdated. Thanks – peleyal Sep 17 '13 at 03:22
  • I have added the issue to the list, its just that the developers.google.com example code isnt valid anymore and the correct example code is on code.google.com wiki – Lawrence Lee Sep 24 '13 at 10:07
0

DotNetOpenAuth would probably help you in getting the authentication piece. After getting an access_token (which DotNetOA will help you get) you will be able to call their API.

Eugenio Pace
  • 14,094
  • 1
  • 34
  • 43