MVC 5 Gmail API Integration

I'm trying to use the GMail API in an MVC 5 project, but I seem to be having difficulty getting this done using Owin middleware for authentication

I can log in through my Google account, and I can also get the user token as such

var googleOptions = new GoogleOAuth2AuthenticationOptions { ClientId = "xxx", ClientSecret = "yyy", SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie, Provider = new GoogleOAuth2AuthenticationProvider() { OnAuthenticated = async ctx => { ctx.Identity.AddClaim(new Claim("urn:tokens:google:accesstoken", ctx.AccessToken)); } }, }; app.UseGoogleAuthentication(googleOptions); 

I get the access token, as expected, but the Google Quicktart Tutorial found here seems to offer a completely different way to perform authentication

Can I use this AccessToken to create the objects required in the tutorial? Or are these two completely different?

+5
source share

Source: https://habr.com/ru/post/1206382/


All Articles