XeroAPI/xero-ruby

xero_client.token_expired?

helmiattastify opened this issue · 3 comments

I got an error when

 credentials = {
        client_id: ENV['XERO_CLIENT_ID'],
        client_secret: ENV['XERO_CLIENT_SECRET'],
        grant_type: 'client_credentials'
      }

      @client ||= XeroRuby::ApiClient.new(credentials: credentials)
      @client.token_expired? 

*** NoMethodError Exception: undefined method `count' for nil:NilClass

but I don't get an error if I pull the token

@client.get_client_credentials_token

before @client.token_expired? 

PETOSS-270

Thanks for raising an issue, a ticket has been created to track your request

Hi @helmiattastify thanks for this. Yes running ApiClient.new(credentials: credentials) generates the token, and to collect the token, you do need to run get_client_credentials_token. Once you have it, you can check the expiry on it.