public async Task <ActionResult> IndexAsync(CancellationToken cancellationToken)
        {
            var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()).
                         AuthorizeAsync(cancellationToken);

            if (result.Credential != null)
            {
                //Ja estem autoritzats i podem cridar el servei de google
                var service = new Google.Apis.Oauth2.v2.Oauth2Service(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = result.Credential,
                    ApplicationName       = "Authentication API Sample",
                });

                UserinfoResource.GetRequest             userInfo = service.Userinfo.Get();
                Google.Apis.Oauth2.v2.Data.Userinfoplus res      = userInfo.Execute();

                /**
                 * A la variable res tenim tota la informació de l'usuari
                 */

                return(View("UserInfo", res));
            }
            else
            {
                return(new RedirectResult(result.RedirectUri));
            }
        }
Beispiel #2
0
 public MeResource(Oauth2Service service)
 {
     this.service = service;
 }
Beispiel #3
0
 public V2Resource(Oauth2Service service)
 {
     this.service = service;
     this._me     = new MeResource(service);
 }
Beispiel #4
0
 public UserinfoResource(Oauth2Service service)
 {
     this.service = service;
     this._v2     = new V2Resource(service);
 }
Beispiel #5
0
 public MeResource(Oauth2Service service, Google.Apis.Authentication.IAuthenticator _authenticator)
 {
     this.service        = service;
     this._authenticator = _authenticator;
 }
Beispiel #6
0
 public V2Resource(Oauth2Service service, Google.Apis.Authentication.IAuthenticator _authenticator)
 {
     this.service        = service;
     this._authenticator = _authenticator;
     this._me            = new MeResource(service, _authenticator);
 }
Beispiel #7
0
 public UserinfoResource(Oauth2Service service, Google.Apis.Authentication.IAuthenticator _authenticator)
 {
     this.service        = service;
     this._authenticator = _authenticator;
     this._v2            = new V2Resource(service, _authenticator);
 }