masm64
masm64

Reputation: 1272

GoogleWebAuthorizationBroker not found exception with .NET Core

I'm trying to access the Google Drive API, and I can successfully log in a user with the use of the Google+ API. I've been following this guide:

https://developers.google.com/drive/v3/web/quickstart/dotnet

I added the needed libraries with the nuget package manager, but still it can't find the GoogleWebAuthorizationBroker class. The weird thing is, that when I add the same Google.Apis.Auth package version 1.18.0 to a simple console application it works flawlessly, but when I add it to my .NET Core 1.0 preview 2 project it simply won't recognize the aforementioned class.

A screenshot including the added packages: enter image description here

My .NET Core source code (no class found here): enter image description here

My console application source code and references (the class can be found here for some reason):

enter image description here

enter image description here

Thanks in advance!

Upvotes: 1

Views: 648

Answers (1)

LarsWA
LarsWA

Reputation: 621

Your console application is running on the full .net framework. That is why GoogleWebAuthorizationBroker is getting resolved there.

I have had the same issues with the Google.Apis against .net core and I ended up running the asp.net Core project on top of the full .net framework. When the Google components work, I plan on switching the framework back to .net core.

I replaced the dotnet framework with the 461 framework like this:

"frameworks": {
    "net461":  {}
  }

And I also had to comment out/remove the dependency on Microsoft.NETCore.App like this:

  "dependencies": {
    "Google.Apis": "1.19.0",
    "Google.Apis.Auth": "1.19.0",
    "Google.Apis.Calendar.v3": "1.19.0.675"
    //"Microsoft.NETCore.App": "1.1.0-preview1-001100-00",
  },

You could also run against both frameworks - I tried doing that, and when you publish the website you go

DOTNET PUBLISH -f 461  

or

DOTNET PUBLISH -f netcoreapp1.0

Depending on the framework. You also then have to select from a dropdown in visual studio, the framework you run against, which ended up being more of a problem. Easier to just comment out the dotnetcore1.0 framework when not needed and just go dotnet publish on my build pipeline ...

There is a thread on the Google .net apis github page about .net core compatibility here. https://github.com/google/google-api-dotnet-client/issues/872#issuecomment-259710682

Expected support for these classes are guesstimated at early 2017.

Hope that help you?

Upvotes: 2

Related Questions