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));
            }
        }
Ejemplo n.º 2
0
 public MeResource(Oauth2Service service)
 {
     this.service = service;
 }
Ejemplo n.º 3
0
 public V2Resource(Oauth2Service service)
 {
     this.service = service;
     this._me     = new MeResource(service);
 }
Ejemplo n.º 4
0
 public UserinfoResource(Oauth2Service service)
 {
     this.service = service;
     this._v2     = new V2Resource(service);
 }
Ejemplo n.º 5
0
 public MeResource(Oauth2Service service, Google.Apis.Authentication.IAuthenticator _authenticator)
 {
     this.service        = service;
     this._authenticator = _authenticator;
 }
Ejemplo n.º 6
0
 public V2Resource(Oauth2Service service, Google.Apis.Authentication.IAuthenticator _authenticator)
 {
     this.service        = service;
     this._authenticator = _authenticator;
     this._me            = new MeResource(service, _authenticator);
 }
Ejemplo n.º 7
0
 public UserinfoResource(Oauth2Service service, Google.Apis.Authentication.IAuthenticator _authenticator)
 {
     this.service        = service;
     this._authenticator = _authenticator;
     this._v2            = new V2Resource(service, _authenticator);
 }