[GH-ISSUE #152] Problem with 'scope' in authentication #70

Closed
opened 2026-02-27 23:20:41 +03:00 by kerem · 3 comments
Owner

Originally created by @Roobxyz on GitHub (Jan 12, 2017).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/152

Hi,

I was trying to do some basic OAuth stuff and came across what seems to be an error regarding the cached OAuth application.

The cached json fails with the following final error:

File "/usr/local/bin/anaconda/lib/python2.7/site-packages/spotipy/oauth2.py", line 158, in _is_scope_subset
    needle_scope = set(needle_scope.split())
AttributeError: 'NoneType' object has no attribute 'split'

my json has
"scope": null
I tried removing the control from lines 137/138 of
/usr/local/bin/anaconda/lib/python2.7/site-packages/spotipy/oauth2.py

 # if scopes don't match, then bail
                if 'scope' not in token_info or not self._is_scope_subset(self.scope, token_info['scope']):
                    return None

which allowed the cached json to work. Just wanted to highlight this.

Thanks

Originally created by @Roobxyz on GitHub (Jan 12, 2017). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/152 Hi, I was trying to do some basic OAuth stuff and came across what seems to be an error regarding the cached OAuth application. The cached json fails with the following final error: ``` File "/usr/local/bin/anaconda/lib/python2.7/site-packages/spotipy/oauth2.py", line 158, in _is_scope_subset needle_scope = set(needle_scope.split()) AttributeError: 'NoneType' object has no attribute 'split' ``` my json has ``` "scope": null``` I tried removing the control from lines 137/138 of `/usr/local/bin/anaconda/lib/python2.7/site-packages/spotipy/oauth2.py` ```python # if scopes don't match, then bail if 'scope' not in token_info or not self._is_scope_subset(self.scope, token_info['scope']): return None ``` which allowed the cached json to work. Just wanted to highlight this. Thanks
kerem closed this issue 2026-02-27 23:20:42 +03:00
Author
Owner

@tcarette commented on GitHub (Mar 3, 2017):

I have the same problem. Why is it closed?

<!-- gh-comment-id:283918316 --> @tcarette commented on GitHub (Mar 3, 2017): I have the same problem. Why is it closed?
Author
Owner

@Roobxyz commented on GitHub (Mar 26, 2017):

Think I was using incorrectly,

util.prompt_for_user_token(username, scope='user-library-read’)

Maybe there should be a default scope set - but specifying it fixes the call.

Cheers,
Reuben

On 3 Mar 2017, at 10:20, Thomas Carette notifications@github.com wrote:

I have the same problem. Why is it closed?


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/plamere/spotipy/issues/152#issuecomment-283918316, or mute the thread https://github.com/notifications/unsubscribe-auth/AFcGWSATOkhAz2H7VZ7xuzAQTY2xDqxQks5rh-lugaJpZM4LiMoa.

<!-- gh-comment-id:289279746 --> @Roobxyz commented on GitHub (Mar 26, 2017): Think I was using incorrectly, util.prompt_for_user_token(username, scope='user-library-read’) Maybe there should be a default scope set - but specifying it fixes the call. Cheers, Reuben > On 3 Mar 2017, at 10:20, Thomas Carette <notifications@github.com> wrote: > > I have the same problem. Why is it closed? > > — > You are receiving this because you modified the open/close state. > Reply to this email directly, view it on GitHub <https://github.com/plamere/spotipy/issues/152#issuecomment-283918316>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFcGWSATOkhAz2H7VZ7xuzAQTY2xDqxQks5rh-lugaJpZM4LiMoa>. >
Author
Owner

@idofr commented on GitHub (Jul 7, 2019):

Over two years later and I'm having the same problem.
Solved it by adding the following line to oauth2.py -> _is_scope_subset(....)
if needle_scope is None and haystack_scope is None: return True

Not sure why the issue was close. I also have the feeling though that I'm using the scopes wrong. Could someone please provide a quick explanation?

Cheers,

<!-- gh-comment-id:509033441 --> @idofr commented on GitHub (Jul 7, 2019): Over two years later and I'm having the same problem. Solved it by adding the following line to oauth2.py -> _is_scope_subset(....) ` if needle_scope is None and haystack_scope is None: return True ` Not sure why the issue was close. I also have the feeling though that I'm using the scopes wrong. Could someone please provide a quick explanation? Cheers,
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#70
No description provided.