Ejemplo n.º 1
0
    public override string ToString()
    {
        if (generateToken is not null && MinutesRemaining < 0.5)
        {
            var token = generateToken();
            this.token = token.token;
            expiry     = token.expiry;

            TokenGenerated?.Invoke(this, EventArgs.Empty);
        }

        return(token !);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the token string.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            if (Url != null && _generateToken != null && MinutesRemaining < 0.5)
            {
                var token = _generateToken(Url);
                _token  = token._token;
                _expiry = token._expiry;

                TokenGenerated?.Invoke(this, EventArgs.Empty);
            }

            return(_token);
        }
Ejemplo n.º 3
0
        private Token GenerateTokenObject(JsonObject tokens, string previousRefreshToken = "")
        {
            var accessToken  = tokens.GetNamedString(AccessTokenJsonName);
            var refreshToken = tokens.GetNamedString(RefreshTokenJsonName, "");

            if (refreshToken == "")
            {
                refreshToken = previousRefreshToken;
            }

            var expiresIn = tokens.GetNamedNumber(ExpiresInJsonName);

            Token freshToken = new Token(accessToken, refreshToken, expiresIn);

            TokenGenerated?.Invoke(new TokenEventArgs(freshToken));
            return(freshToken);
        }