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