public void AuthGetAccessToken(AuthArgs args)
        {
            var requestToken       = args.InternalData["requestToken"] as string;
            var requestTokenSecret = args.InternalData["requestTokenSecret"] as string;

            var hyvesSession = this.LoadHyvesSession(args);

            var      hyvesRequest = new HyvesRequest(hyvesSession);
            string   userId;
            string   accessTokenSecret;
            DateTime expireDate;
            var      accessToken = hyvesRequest.CreateAccessToken(requestToken, requestTokenSecret, out accessTokenSecret, out userId, out expireDate);

            var authCompletedArgs = new AuthCompletedArgs
            {
                Application                 = args.Application,
                AccessToken                 = accessToken,
                AccessTokenSecret           = accessTokenSecret,
                CallbackPage                = args.CallbackPage,
                ExternalData                = args.ExternalData,
                AttachAccountToLoggedInUser = args.AttachAccountToLoggedInUser,
                IsAsyncProfileUpdate        = args.IsAsyncProfileUpdate
            };

            if (!string.IsNullOrEmpty(args.CallbackType))
            {
                this.InvokeAuthCompleted(args.CallbackType, authCompletedArgs);
            }
        }
    public void AuthGetAccessToken(AuthArgs args)
    {
      var requestToken = args.InternalData["requestToken"] as string;
      var requestTokenSecret = args.InternalData["requestTokenSecret"] as string;

      var hyvesSession = this.LoadHyvesSession(args);

      var hyvesRequest = new HyvesRequest(hyvesSession);
      string userId;
      string accessTokenSecret;
      DateTime expireDate;
      var accessToken = hyvesRequest.CreateAccessToken(requestToken, requestTokenSecret, out accessTokenSecret, out userId, out expireDate);

      var authCompletedArgs = new AuthCompletedArgs
      {
        Application = args.Application,
        AccessToken = accessToken,
        AccessTokenSecret = accessTokenSecret,
        CallbackPage = args.CallbackPage,
        ExternalData = args.ExternalData,
        AttachAccountToLoggedInUser = args.AttachAccountToLoggedInUser,
        IsAsyncProfileUpdate = args.IsAsyncProfileUpdate
      };
      if (!string.IsNullOrEmpty(args.CallbackType))
      {
        this.InvokeAuthCompleted(args.CallbackType, authCompletedArgs);
      }
    }
Exemple #3
0
        public void AuthGetAccessToken(AuthArgs args)
        {
            HttpRequest request = HttpContext.Current.Request;

            if (!string.IsNullOrEmpty(request.QueryString.Get("error")))
            {
                return;
            }
            else
            {
                string str = request.QueryString.Get("code");
                if (string.IsNullOrEmpty(str))
                {
                    return;
                }
                else
                {
                    this._provider.ClientIdentifier = (args.Application.ApplicationKey);
                    this._provider.ClientSecret     = (args.Application.ApplicationSecret);
                    List <string>      list1  = GetScopes();
                    AuthorizationState state1 = new AuthorizationState(list1);
                    state1.Callback =
                        (new Uri(WebUtil.GetFullUrl("/layouts/Social/Connector/SocialLogin.ashx?type=access")));
                    AuthorizationState state = state1;
                    try
                    {
                        this._auth = this._provider.ProcessUserAuthorization(str, state);
                    }
                    catch (WebException exception)
                    {
                        using (WebResponse response = exception.Response)
                        {
                            using (Stream stream = response.GetResponseStream())
                            {
                                if (stream != null)
                                {
                                    string message = new StreamReader(stream).ReadToEnd();
                                    ExecutingContext.Current.IoC.Get <ILogManager>(new IParameter[0]).LogMessage(message,
                                                                                                                 Sitecore.Social.Infrastructure.Logging.LogLevel.Error, this, exception);
                                }
                            }
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(args.CallbackType))
            {
                AuthCompletedArgs args1 = new AuthCompletedArgs();
                args1.Application       = args.Application;
                args1.AccessTokenSecret = this._auth.AccessToken;
                args1.RefreshToken      = this._auth.RefreshToken;
                args1.AccessTokenSecretExpirationDate = this._auth.AccessTokenExpirationUtc;
                args1.AccessTokenSecretIssueDate      = this._auth.AccessTokenIssueDateUtc;
                args1.CallbackPage = args.CallbackUrl;
                args1.ExternalData = args.ExternalData;
                args1.AttachAccountToLoggedInUser = args.AttachAccountToLoggedInUser;
                args1.IsAsyncProfileUpdate        = args.IsAsyncProfileUpdate;
                AuthCompletedArgs authCompletedArgs = args1;
                base.InvokeAuthCompleted(args.CallbackType, authCompletedArgs);
            }
        }