okta / okta-jwt-verifier-python

okta-jwt-verifier-python
https://github.com/okta/okta-jwt-verifier-python
Apache License 2.0
33 stars 17 forks source link

'AccessTokenVerifier' object has no attribute 'parse_token' #37

Closed glmourad closed 2 years ago

glmourad commented 2 years ago

Hi,

I'm getting the following error when invoking AccessTokenVerifier(issuer=issuer, audience=audience), @okta-jwt-verifier==0.2.3: 'AccessTokenVerifier' object has no attribute 'parse_token'

Thanks

serhiibuniak-okta commented 2 years ago

@glmourad Hi, if I understand you correctly, you got an error after the following steps:

(Python 3.8.12)
>>> import okta_jwt_verifier
>>> okta_jwt_verifier.__version__
'0.2.3'
>>> issuer = 'https://test_issuer.com'
>>> audience = 'test_audience'
>>> okta_jwt_verifier.AccessTokenVerifier(issuer=issuer, audience=audience)
<okta_jwt_verifier.jwt_verifier.AccessTokenVerifier object at 0x10a081340>
>>> 

In this case, I can't reproduce the error and don't see the reason which may cause this error. Could you please, provide more details? i.e. python version, code sample, etc.

glmourad commented 2 years ago

Sorry,

Actually I have updated the version from 0.2.1 to 0.2.3 and now the last line of this function is throwing the error:

async def is_access_token_valid(issuer, audience, access_token): access_token_verifier = AccessTokenVerifier( issuer=issuer, audience=audience) await access_token_verifier.verify(access_token) return access_token_verifier.parse_token(access_token)

serhiibuniak-okta commented 2 years ago

Yes, that's fine. We have deprecated JWTVerifier and refactored our codebase a bit. Now, AccessTokenVerifier and IDTokenVerifier can be used only for verifying relevant token, i.e. they have only one method - verify. To parse token manually, you should use JWTUtils class or the main class which contains all needed functionality - BaseJWTVerifier. I guess, we'll update our README to make it more clear.

glmourad commented 2 years ago

Thanks. I'm using JWTUtils now.

serhiibuniak-okta commented 2 years ago

@glmourad Thank you for letting us know it works. I'm closing this issue as resolved. Feel free to reopen this issue or create a new one if your problem exists still. Thanks for using OKTA!