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.

Each time the oauthlib library is changed, I have to change my code because the behaviour changes. So, can you fix the version of the libraries that you use? At least you should fix the mayor number of the dependencies since when this number changes, the API often changes.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:23 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
akshar-raajcommented, Jan 30, 2015

In case somebody is still facing this issue, you can add os.environ[‘OAUTHLIB_RELAX_TOKEN_SCOPE’] = “1”. I am not sure if this is the best solution, but it was a quick fix which worked for me.

2reactions
benjaminwhitecommented, Nov 14, 2014

I also encounter

Warning: Scope has changed from “…” to “”.

Here’s why it occurs (at least for me):

In oauth2_session.py, fetch_token and refresh_token both call (lines 199 and 257):

self._client.parse_request_body_response(r.text, scope=self.scope)

It’s important to note that r.text does not contain details about scope.

Then in, oauthlib/oauth2/rfc6749/parameters.py, the r.text value is passed into a OAuth2Token object (375):

params = OAuth2Token(params, old_scope=scope)

The OAuth2Token searches for scope inside params (r.text’s value) but finds none, so assigns self._new_scope to an empty set:

self._new_scope = set(utils.scope_to_list(params.get('scope', '')))

validate_token_parameters is then called on the OAuth2Token which is where the trouble occurs:

if params.scope_changed:
    message = 'Scope has changed from "{old}" to "{new}".'.format(
        old=params.old_scope, new=params.scope,
    )
    scope_changed.send(message=message, old=params.old_scopes, new=params.scopes)
    if not os.environ.get('OAUTHLIB_RELAX_TOKEN_SCOPE', None):
        w = Warning(message)
        w.token = params
        w.old_scope = params.old_scopes
        w.new_scope = params.scopes
        raise w

params.scope_changed compares new_scope to old_scope, and returns true because the old_scope has a value and new_scope doesn’t.

This leads to the warning being raised.

The solution I found was to not pass scope into parse_request_body_response:

self._client.parse_request_body_response(r.text)

If you’d like, I can create a pull request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use apt-get to fix missing and broken packages - Linux Hint
In this article, we will learn how to fix the missing dependencies and broken packages using the apt-get command. Note that, we have...
Read more >
How to Fix Unmet Dependencies Error on Ubuntu - Appuals.com
How to Fix Unmet Dependencies Error on Ubuntu · Method 1: Use the -f parameter · Method 2: Use Aptitude · Method 3:...
Read more >
Ubuntu fix dependency problems - apt
3 Answers 3 · sudo cp /etc/apt/sources.list /etc/apt/sources.list.bk · Run the following commands in order: sudo apt-get clean sudo apt-get update ...
Read more >
How to Find and Fix Broken Packages on Linux - MakeUseOf
Broken packages need repairing or the software won't run. Here's how to find the broken packages and fix them in Linux.
Read more >
How to fix npm dependency hell - Sylhare's blog
How to fix npm dependency hell. February 09, 2022. Some context. NodeJS ecosystem is built on top of countless packages that sometime feels...
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