Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect page does not automatically close. #658

Closed
MartijnVogelaar opened this issue Mar 22, 2021 · 1 comment
Closed

Redirect page does not automatically close. #658

MartijnVogelaar opened this issue Mar 22, 2021 · 1 comment
Labels

Comments

@MartijnVogelaar
Copy link

MartijnVogelaar commented Mar 22, 2021

Describe the bug
Using the oath2 module the user is eventually redirected to the redirect page which should close automatically or should be closed by a click on a button. It however does not work and throws the following error in the browser's console:

Scripts may not close windows that were not opened by script.

In the following piece of code: https://github.com/plamere/spotipy/blob/dc89a00113e98b26b4932b582cb4f7b4449fcd4d/spotipy/oauth2.py#L1282-L1293
the page tries to close itself by doing a window.close() on line 1282 and also tries to add a button on line 1292 which should close the current window, but it does not.
This is the case in both Chromium-based browsers as in Firefox see: firefox definition .

This behavior is confusing for some users, someone opened an issue on my project regarding this: MartijnVogelaar/krunner-spotify#26

``

Your code

from spotipy.oauth2 import SpotifyOAuth
from spotipy.oauth2 import SpotifyPKCE
import spotipy

CLIENT_ID = "4308514e1497441b9da05278342b8289"
REDIRECT_URI = "http://localhost:8888/callback"

auth_manager = SpotifyPKCE(client_id=CLIENT_ID,
                                redirect_uri=REDIRECT_URI,
                                scope="user-modify-playback-state")
spotify = spotipy.Spotify(auth_manager=auth_manager)
spotify.volume(0)

Expected behavior
The expected result is obviously that the window is automatically closed, or closed by clicking the button.

Output
As said earlier the browser console outputs:

Scripts may not close windows that were not opened by script.

Environment:

  • OS: Kubuntu 20.0.4 / Manjaro KDE
  • Python version: 3.8.5
  • Spotipy version: 2.17.1

Suggestion

I would suggest to just remove the entire button and tell the user that the window can be closed by the user.

@dieser-niko
Copy link
Member

Closing as there's no activity (and also it seems to be fixed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants