0

I would like to work with Google's .NET API while using OAuth 2.0 flow for devices.

I didn't find any way to use GoogleWebAuthorizationBroker or Create UserCredentials object in .NET when working with OAuth 2.0 flow for devices.

Is there a way to make the above requirement work? or should I use only REST API?

Thanks, Ronen

Burgaz
  • 237
  • 7
  • 14

2 Answers2

1

Assuming you refer to this flow: https://developers.google.com/accounts/docs/OAuth2ForDevices, it is not supported in the Google APIs Client Library for .NET. So you need to build it yourself though you may be able to reuse large parts of Google's stuff.

Notice that the "OAuth 2.0 flow for devices" is not a standardized OAuth 2.0 flow, so support is not ubiquitous. Also, the Google says elsewhere:

If your app will run on devices that do not have access to a system browser, or devices with limited input capabilities (for example, if your app will run on game consoles, video cameras, or printers), then see Using OAuth 2.0 for Devices.

If that's really your use case you should pursue my suggestions, otherwise you should switch to https://developers.google.com/accounts/docs/OAuth2InstalledApp (see the flow chart on the right side there as well).

Hans Z.
  • 50,496
  • 12
  • 102
  • 115
0

The .NET client library for Google APIs supports OAuth 2.0 and it supports several devices including Windows Phone 8.1 and Windows Store applications. The OAuth 2.0 documentation (including snippets) is available at: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth.

My obvious recommendation is to use the library, because it will refresh tokens for you automatically (using the stored refresh token) and it's a light OO library which will do a lot of "magics" for you (such as media upload).

By the way, our samples repository includes full sample for a universal app, take a look at Blogger.Sample for more details.

peleyal
  • 3,472
  • 1
  • 14
  • 25