Beispiel #1
0
        public String GetRefreshedToken()
        {
            if (IsExpired)
            {
                var app = ThirdPartySelector.GetApp(App);
                try
                {
                    Global.Logger.Debug("Refresh token for app: " + App);

                    var refreshUrl = app.GetRefreshUrl();

                    var refreshed = OAuth20TokenHelper.RefreshToken(refreshUrl, this);

                    if (refreshed != null)
                    {
                        AccessToken  = refreshed.AccessToken;
                        RefreshToken = refreshed.RefreshToken;
                        ExpiresIn    = refreshed.ExpiresIn;
                        Timestamp    = DateTime.UtcNow;

                        SaveToken(this);
                    }
                }
                catch (Exception ex)
                {
                    Global.Logger.Error("Refresh token for app: " + app, ex);
                }
            }
            return(AccessToken);
        }
Beispiel #2
0
        public String GetRefreshedToken()
        {
            if (IsExpired)
            {
                var app = ThirdPartySelector.GetApp(App);
                try
                {
                    var refreshed = app.RefreshToken(RefreshToken);

                    if (refreshed != null)
                    {
                        AccessToken  = refreshed.AccessToken;
                        RefreshToken = refreshed.RefreshToken;
                        ExpiresIn    = refreshed.ExpiresIn;
                        Timestamp    = DateTime.UtcNow;
                    }
                }
                catch (Exception ex)
                {
                    Global.Logger.Error("Refresh token for app: " + app, ex);
                }
            }
            return(AccessToken);
        }