Alation / Allie-SDK

A Python library for the Alation REST APIs.
https://alation.github.io/Allie-SDK/
Apache License 2.0
9 stars 2 forks source link

Sample fails with AttributeError: 'NoneType' object has no attribute 'token_status' #16

Open james-mesney opened 3 months ago

james-mesney commented 3 months ago

I had another run with the (latest) Allie SDK and the sample code for getting data health rules. It fails with a different error:

(venv) james.mesney@james-mesney-RFG6NCQPG3 Allie-SDK % /Users/james.mesney/Documents/code/Allie-SDK/venv/bin/python /Users/james.mesn
ey/Documents/code/Allie-SDK/datahealthrules.py
ERROR MESSAGE: Error submitting the POST Request to: /integration/v1/validateRefreshToken/
ERROR CODE: 401000
ERROR DETAIL: Refresh token provided is expired or revoked.
Traceback (most recent call last):
  File "/Users/james.mesney/Documents/code/Allie-SDK/datahealthrules.py", line 3, in <module>
    alation = allie.Alation(
              ^^^^^^^^^^^^^^
  File "/Users/james.mesney/Documents/code/Allie-SDK/allie_sdk/alation.py", line 72, in __init__
    self.access_token = self.authentication.create_access_token().api_access_token
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/james.mesney/Documents/code/Allie-SDK/allie_sdk/methods/authentication.py", line 55, in create_access_token
    if refresh_status.token_status.upper() != 'ACTIVE':
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'token_status'
(venv) james.mesney@james-mesney-RFG6NCQPG3 Allie-SDK % 

The refresh token I'm using is active and good until Aug 30. Any idea what causes the _AttributeError: 'NoneType' object has no attribute 'tokenstatus'?

Thanks.

james-mesney commented 3 months ago

Update: In desperation, I generated another, new refresh token and this code is now working! I don't know why the original token doesn't work.

(The AttributeError error message does not help one identify the problem)

marioaburto-alation commented 2 months ago

hi @james-mesney , glad that it is working for you now and thank you for your feedback. We are going to work on adding a better error message for when the refresh token is not valid.