question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Unsupported token type: User Access Token

See original GitHub issue

Hello. I’ve got some error after successfully obtain a token from eBay.

As you can see at its documentation eBay returns "token_type": "User Access Token"

After getting the token without having a problem, when I try to request anything from its endpoint I get;

Traceback (most recent call last):
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/bin/rods", line 11, in <module>
    load_entry_point('rpi-order-data-sync', 'console_scripts', 'rods')()
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/thiras/HDD/freelancer/contentassasin/rpi-order-data-sync/rpi_order_data_sync/main.py", line 132, in sync_ebay_orders
    orders = ebay.get(
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py", line 477, in request
    url, headers, data = self._client.add_token(
  File "/home/thiras/.local/share/virtualenvs/rpi-order-data-sync-tA0i1rrc/lib/python3.8/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 192, in add_token
    raise ValueError("Unsupported token type: %s" % self.token_type)
ValueError: Unsupported token type: User Access Token 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
sambraggcommented, Jun 21, 2020

@thiras I couldn’t get your solution to work. Incase anyone else has this issue, what I ended up doing was the following:

import json
from oauthlib.common import to_unicode

self.oauth.register_compliance_hook('access_token_response', self.non_compliant_token)
self.oauth.register_compliance_hook('refresh_token_response', self.non_compliant_token)

def non_compliant_token(self, response):
        token = json.loads(response.text)
        token["token_type"] = "Bearer"
        fixed_token = json.dumps(token)
        response._content = to_unicode(fixed_token).encode("utf-8")
        return response

This avoids having to create a fake class etc.

1reaction
thirascommented, May 5, 2020

@sambragg sure. Check my solution here; https://stackoverflow.com/a/61001852/4132845

Also check register_compliance_hook at the official docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

samples-python-flask/main.py at master - GitHub
Get tokens and validate. if not exchange.get("token_type"):. return "Unsupported token type. Should be 'Bearer'.", 403. access_token ...
Read more >
eBay and Authlib Unconventional token type - Stack Overflow
The problem is eBay's token response has an unconventional token type named "User Access Token" instead of "Bearer".
Read more >
Source code for oauthlib.oauth2.rfc6749.clients.base
:param access_token: An access token (string) used to authenticate requests to ... raise ValueError("Unsupported token type: %s" % self.token_type) if not ...
Read more >
Access Token Error Response and Codes - Tutorialspoint
This error occurs when there is a missing parameter that includes multiple credentials, unsupported parameter value. 400. 2. unauthorized_client. The ...
Read more >
Python flask - cannot validate acess token
For the moment, all the flow is good until the callback. The callback fails because the access token is invalid. It seems the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found