Reputation: 145
I got the following error on python when access_token is passed to “verify_access_token”. Does anyone know how to fix this error? I used "okta-jwt-verifier 0.2.3"
from okta_jwt_verifier import JWTVerifier
def authenticate(self, request):
access_token = request.META.get('HTTP_AUTHORIZATION')
loop = asyncio.new_event_loop()
jwt_verifier = JWTVerifier(issuer='https://devtest.okta.com/oauth2/default',
client_id='12345', audience='api://default')
loop.run_until_complete(jwt_verifier.verify_access_token(access_token))
ERROR
JWTValidationException Invalid header string: ‘utf-8’ codec can’t decode bytes in position 1-2: invalid continuation byte
Request Method: GET Request URL: http://127.0.0.1:8000/getdata/ Django Version: 2.2.10 Exception Type: JWTValidationException Exception Value: Invalid header string: ‘utf-8’ codec can’t decode bytes in position 1-2: invalid continuation byte Exception Location: C:\WEB\project\pyenv\lib\site-packages\okta_jwt_verifier\jwt_verifier.py in verify_access_token, line 101
Upvotes: 0
Views: 1423
Reputation: 145
I found the problem after sharing this question with OKTA dev team as per following:
Word of “Bearer” needs to be removed if access_token object has it. This can be done through a string replacement as below the line.
access_token = request.META.get('HTTP_AUTHORIZATION', '').replace('Bearer', '').strip()
Upvotes: 1