Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .net core support for Google.Apis.Auth.Mvc #933

Closed
Deren-Liao opened this issue Mar 15, 2017 · 30 comments
Closed

Add .net core support for Google.Apis.Auth.Mvc #933

Deren-Liao opened this issue Mar 15, 2017 · 30 comments
Assignees
Labels

Comments

@Deren-Liao
Copy link

@Deren-Liao Deren-Liao commented Mar 15, 2017

My understanding, currently Google.Apis.Auth.Mvc does not build for .net core. Please support .net core.

@jskeet
Copy link
Collaborator

@jskeet jskeet commented Mar 16, 2017

Assigned to Chris for initial comment, as I can't remember what the status is here.

Although if Google.Apis.Auth.Mvc targets "full" ASP.NET, I'm not sure it makes much sense to support it on .NET Core - we'd want something which targets ASP.NET Core instead. If it's neutral though (it doesn't look like it has a dependency on ASP.NET...) it would make more sense.

@chrisdunelm
Copy link
Collaborator

@chrisdunelm chrisdunelm commented Apr 3, 2017

I'll have a look soonish to see if .NET Core support for Google.Apis.Auth.Mvc makes sense.
And even if it doesn't, it could do with being updated to use a targeted nuspec.

@clement911
Copy link

@clement911 clement911 commented Apr 24, 2017

Hi there,
I'm also looking at using oauth2 from my asp.net core to access the drive api and sheets api.
Is it possible? Is there a sample?

Update: If it makes any difference, I'm using asp.net core on top the full .net framework (not .net core) so I'm happy to use any lower level apis that may be available in the existing nuget package targeted at the full .net framework. I can probably just reimplement the controller myself and inherit from the asp.net core controller class instead of the asp.net one, but I'm just not sure how to go about this...

Thanks

@clement911
Copy link

@clement911 clement911 commented Apr 24, 2017

Maybe using Google.Apis.Auth instead of Google.Apis.Auth.MVC?

@LindaLawton
Copy link
Collaborator

@LindaLawton LindaLawton commented Apr 24, 2017

only thing i am aware of https://github.com/google/google-api-dotnet-client-samples/tree/master/Calendar.ASP.NET.MVC5

@clement911
Copy link

@clement911 clement911 commented Apr 24, 2017

I believe this uses asp.net 5 but not asp.net core...

@LindaLawton
Copy link
Collaborator

@LindaLawton LindaLawton commented Apr 24, 2017

That's all we have then. I don't think anyone has done any Core samples yet.

@clement911
Copy link

@clement911 clement911 commented Apr 24, 2017

I see. I guess I'll have to figure out on my own.

@LindaLawton
Copy link
Collaborator

@LindaLawton LindaLawton commented Apr 24, 2017

If you have any issues put up a question on stackoverflow tag it google-api-dotnet-client I will try and help

@chrisdunelm chrisdunelm added this to the v1.27 milestone Apr 24, 2017
@bugproof
Copy link

@bugproof bugproof commented May 19, 2017

I would like to see some NET core MVC samples too.

@murat-mehmet
Copy link

@murat-mehmet murat-mehmet commented Sep 4, 2017

Please help me on Stack overflow about this issue. I'm totally stuck and my app is vulnerable at the moment because I cannot verify in-app purchases on the server side...

@jskeet
Copy link
Collaborator

@jskeet jskeet commented Sep 4, 2017

I've answered the Stack Overflow question, but please note that the MVC package is designed for user authentication, not service account authentication.

@neooleg
Copy link

@neooleg neooleg commented Oct 16, 2017

@jskeet, do you have any a link for Stack Overflow or other reference for User authentication accessing Google API, e.g. Calendar API like in the sample. I still can't find anything useful for awhile.

Thanks in advance!

@jskeet
Copy link
Collaborator

@jskeet jskeet commented Oct 16, 2017

@neooleg: From what platform? You say "like in the sample" - what are you trying to do that's different from the sample?

@neooleg
Copy link

@neooleg neooleg commented Oct 16, 2017

@jskeet: Platfrom is .NET Core 2.0

I try to do exactly the same -- call Calendar API using .NET Core and Google OAuth 2.0.

However, the following code from the sample doesn't work on Core because OWIN I guess:

var identity = await HttpContext.GetOwinContext().Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ApplicationCookie);
var userId = user.FindFirstValue(MyClaimTypes.GoogleUserId);

@jskeet
Copy link
Collaborator

@jskeet jskeet commented Oct 16, 2017

But the sample isn't using .NET Core - it's using ASP.NET MVC.

Basically, what you're requesting is that this issue is fixed - ASP.NET Core support in the same style as Google.Apis.Auth.Mvc.

@neooleg
Copy link

@neooleg neooleg commented Oct 16, 2017

But the sample isn't using .NET Core - it's using ASP.NET MVC.

Sure, I know. However, what I've missed it seems -- is that not only the sample is outdated (i.e. isn't .NET Core), but the library which required to allow API calls working is also not updated for .NET Core.

In other words, there is no ability to call Calendar API from .NET Core for now.
Am I correct?

@jskeet
Copy link
Collaborator

@jskeet jskeet commented Oct 16, 2017

The sample isn't "outdated" in that there are still plenty of users who will be using ASP.NET rather than ASP.NET Core.

And you certainly can call the Calendar API from ASP.NET Core now - but you'd need to reimplement the functionality provided by the Google.Apis.Auth.Mvc library. All the code is available, and there's not a huge amount of it. If you wanted to create a pull request to fix this issue yourself, that would be most welcome - it's just been lower down our priority list than other work. (There may be other OAuth2 libraries that would do the bulk of the work, leaving you just to create the final token, too.)

@neooleg
Copy link

@neooleg neooleg commented Oct 16, 2017

@jskeet: Thanks for complete answer! I'll investigate it detailed.

P.S. Apologize me to use inappropriate word for sample characteristic. I just meant it doesn't support .NET Core.

@buzallen
Copy link

@buzallen buzallen commented Oct 23, 2017

I forked this and have a version that works for Mvc Core apps. Wanted to pass what I did by and if the way I set it up is OK then I'll submit a PR.

Notes:

  • I added a project 'Google.ApisAuth.AspMvcCore'
  • Used the namespace 'Google.Apis.Auth.OAuth2.AspMvcCore'
  • Moved the target to netstandard 1.6 for this project (needed for some references)
  • I couldn't find a replacement in core for the '[AsyncTimeout(10000)]' attribute on the IndexAsync Action
  • When parsing the query string that was returned in the 'AuthorizationCodeActionFilter' the error keys were not in the dictionary (not sure if this is intentional) but it caused an exception so I first checked if the key exists. This was not an issue in the mvc 5 version.

@neooleg
Copy link

@neooleg neooleg commented Nov 4, 2017

@buzallen thanks for update!

Few questions:

  1. Do you plan to update/create a sample?
  2. Why you didn't create a PR yet?

@buzallen
Copy link

@buzallen buzallen commented Nov 4, 2017

@neooleg

1 - I certainly can create a sample, I have a basic proof of concept app I created when I updated the library.
2 - I'm new to contributing and since what I did involved added a new project and namespace I thought I might run it by the project owners to verify it matched the way they do things before I submitted a PR.

If anyone has thoughts on this or if it makes sense for me to generate a PR with what I have let me know.

@neooleg
Copy link

@neooleg neooleg commented Nov 4, 2017

@buzallen

  1. It make sense to add it for sure.
  2. IMO -- I see no reasons to don't create a PR, so feel free to do it. Otherwise, project members will concern something inside PR, don't worry. Moreover, @jskeet above mentioned about PR, so go ahead.

@larini
Copy link

@larini larini commented Nov 4, 2017

@buzallen

I´m looking for a working sample too.

@wexotht
Copy link

@wexotht wexotht commented Nov 21, 2017

@buzallen Could you add the PR and sample, please?

@neooleg
Copy link

@neooleg neooleg commented Nov 21, 2017

@larini, @ThomasHT pls check comments in #1109 to be aware.

@Trycoder
Copy link

@Trycoder Trycoder commented Aug 21, 2018

Hi,
Can i Use the flow as mentioned in https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web-applications-aspnet-mvc for Web API 2 also?

chrisdunelm added a commit that referenced this issue Nov 28, 2018
@chrisdunelm
Copy link
Collaborator

@chrisdunelm chrisdunelm commented Nov 28, 2018

Support for ASP.NET Core 2.0+ is now available in the Google.Apis.Auth.AspNetCore beta package on nuget: https://www.nuget.org/packages/Google.Apis.Auth.AspNetCore/1.36.1-beta01

@oliverdejohnson
Copy link

@oliverdejohnson oliverdejohnson commented Jun 15, 2020

@chrisdunelm is there a sample code for using this anywhere? https://www.nuget.org/packages/Google.Apis.Auth.AspNetCore/1.36.1-beta01

@LindaLawton
Copy link
Collaborator

@LindaLawton LindaLawton commented Jun 16, 2020

the only example we have for asp .net core is the tests themselves. I tried to put together a sample a few weeks ago and was unable to get it to work. It would authenticate but when trying to access an API I was getting unauthorized I suspect it was cookie related I haven't had time to look into it further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests