Qovery Python Client - Invalid JWT serialization error

Where to find Bearer token for api?
In case, when I use api key from qovery console,
sample of code raises exception:

 configuration = qovery.Configuration(
        host="https://api.qovery.com",
        access_token='qov_*****'
    )

    def __init__(self):
        self.configuration.debug = True
        self.configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

    def get_app_list(self):
        with qovery.ApiClient(self.configuration) as api_client:
            # Create an instance of the API class
            api_instance = applications_api.ApplicationsApi(api_client)
            environment_id = "environmentId_example"  # str | Environment ID

            # example passing only required values which don't have defaults set
            try:
                # List applications
                api_response = api_instance.list_application(environment_id)
                print(api_response)
            except qovery.ApiException as e:
                print("Exception when calling ApplicationsApi->list_application: %s\n" % e)

“An error occurred while attempting to decode the Jwt: Invalid JWT serialization: Missing dot delimiter(s)”

Hi @am0s ,

Actually, instead of using this:

self.configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

can you use

self.configuration.api_key_prefix['ApiKeyAuth'] = 'Token'

An API token is not a JWT token but a long-live stateful token.

That didn’t help.

“An error occurred while attempting to decode the Jwt: Invalid JWT serialization: Missing dot delimiter(s)”

How to obtain JWT token for bearer auth?

Sorry, but I think it’s:

self.configuration.api_key_prefix['Authorization'] = 'Token'

Can you try?

No luck, same error

An error occurred while attempting to decode the Jwt: Invalid JWT serialization: Missing dot delimiter

I’ll try this on my end to see how to solve this issue.

Hello @am0s,

By curiosity, did you try to set the api key like this ?:

configuration.api_key['ApiKeyAuth'] = 'YOUR_API_KEY'

According to our generated documentation for qovery python client, this should work (e.g https://github.com/Qovery/qovery-client-python/blob/master/docs/AccountInfoApi.md#get_account_information)

` configuration = qovery.Configuration(
host=“https://api.qovery.com”,
)

def __init__(self):
    self.configuration.debug = True
    self.configuration.api_key['ApiKeyAuth'] = 'qov_****'

def get_app_list(self):
    with qovery.ApiClient(self.configuration) as api_client:
        # Create an instance of the API class
        api_instance = applications_api.ApplicationsApi(api_client)
        environment_id = "environmentId_example"  # str | Environment ID

        # example passing only required values which don't have defaults set
        try:
            # List applications
            api_response = api_instance.list_application(environment_id)
            print(api_response)
        except qovery.ApiException as e:
            print("Exception when calling ApplicationsApi->list_application: %s\n" % e)

`

Error 401

Okay so your token is well taken in account in the Authorization header.

The 401 means it doesn’t give you access to the resource: either your token is wrong (copy/paste issue ?) or it doesn’t exist anymore in your organization.
Can you check on it ?

By the way you can also check the validity of your token by doing a simple curl:

curl 'https://api.qovery.com/organization' -H 'Authorization: Token qov_XXX'

This should return the organization linked to the token

Successfully with token

Can you share me privately the response of the above curl + the environment id you target in your python script ?