Esempio n. 1
0
        public void SetEbayAuth(OAuthToken userToken, OAuthToken refreshToken, long companyId)
        {
            try
            {
                var auth = new EbayAuth
                {
                    UserToken = new EbayOAuthToken
                    {
                        Token      = userToken.Token,
                        Expiration = userToken.ExpiresOn,
                        Type       = EbayOAuthTokenType.USERTOKEN
                    },
                    RefreshToken = new EbayOAuthToken
                    {
                        Token      = refreshToken.Token,
                        Expiration = refreshToken.ExpiresOn,
                        Type       = EbayOAuthTokenType.REFRESHTOKEN
                    }
                };

                keyManager.SetEbayAuthByCompanyId(companyId, auth);
            }
            catch (Exception ex)
            {
                telemetryClient.TrackException(ex);
            }
        }
Esempio n. 2
0
        public static EBayAuthStatus StartSession()
        {
            log.Info("Starting session, getting ");
            var auth = EbayAuth.CreateNewAuthRequest();

            return(new EBayAuthStatus
            {
                SessionId = auth.SessionId,
                LoginUrl = auth.LoginUrl
            });
        }
Esempio n. 3
0
        public static EBayAuthStatus ConfirmAuthentication(string sessionId)
        {
            EbayAuthenticatedCredentials auth;

            try
            {
                auth = EbayAuth.CompleteEbayAuthentication(sessionId);
            }
            catch (Exception)
            {
                throw new Exception("Unable to complete authentication. Please ensure you have logged into eBay.");
            }

            return(new EBayAuthStatus
            {
                SessionId = sessionId,
                Token = auth.Token,
                Username = auth.EbayUsername
            });
        }
Esempio n. 4
0
 public bool SetEbayAuthByCompanyId(long companyId, EbayAuth auth)
 {
     try
     {
         Task <bool> userTokenTask    = SetEbayTokenByCompanyId(companyId, auth.UserToken);
         Task <bool> refreshTokenTask = SetEbayTokenByCompanyId(companyId, auth.RefreshToken);
         Task.WaitAll(userTokenTask, refreshTokenTask);
         if (!userTokenTask.Result || !refreshTokenTask.Result)
         {
             throw new Exception($"Error while setting ebay auth, user token result was {userTokenTask.ToString()} and refresh token result was {refreshTokenTask.ToString()}");
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         telemetryClient.TrackException(ex);
         return(false);
     }
 }