static void Main(string[] args) { Authenticator auth = Authenticator.Instance; auth.Authenticate(authUrl, clientId, clientSecret); //string token = auth.GetToken(); DecodedToken dt = new DecodedToken(auth.GetToken()); Console.WriteLine(dt.GetDecodedToken().application_id); Console.WriteLine(dt.GetDecodedToken().iss); Console.WriteLine(dt.GetDecodedToken().iat); Console.WriteLine(dt.GetDecodedToken().exp); Console.Read(); }
public XPress(string baseApiUrl) { this.baseApiUrl = baseApiUrl; this.restClient = new RestClient(baseApiUrl); DecodedToken dt = new DecodedToken(Authenticator.Instance.GetToken()); if (Util.ConvertUnixTime(dt.GetDecodedToken().exp) <= DateTime.Now) { Authenticator.Instance.RefreshToken(); this.restClient.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(Authenticator.Instance.GetToken(), "Bearer"); } else { this.restClient.Authenticator = new OAuth2AuthorizationRequestHeaderAuthenticator(Authenticator.Instance.GetToken(), "Bearer"); } }