sigma67 / spotify_to_ytmusic

Clone a Spotify playlist to YouTube Music
MIT License
895 stars 67 forks source link

Google OAuth not working #62

Closed Rexadev closed 8 months ago

sigma67 commented 1 year ago

Well, did you try again?

z3t4m4n commented 1 year ago

Hi, same issue. I placed a try/except on /home/$HOME/.local/lib/python3.11/site-packages/ytmusicapi/auth/oauth.py ( ytmusicapi 1.1.1):

    def _parse_token(response) -> Dict:                                                                                                                 
        try:                                                                                                                                            
            token = response.json()                                                                                                                     
            token["expires_at"] = int(time.time()) + int(token["expires_in"])                                                                           
        except Exception as error:                                                                                                                      
            print("An error occurred:", type(error).__name__) # An error occurred: NameError                                                            
            print(response.json())                                                                                                                      
        return token 
$ spotify_to_ytmusic setup                                                                                                            
Choose which API to set up                                                                                                                              
(1) Spotify                                                                                                                                             
(2) YouTube                                                                                                                                             
(3) both                                                                                                                                                
2                                                                                                                                                       
Go to https://www.google.com/device?user_code=XXXX-XXXX, finish the login flow and press Enter when done, Ctrl-C to abort
<Response [400]>                                                                                                                                        
An error occurred: KeyError                                                                                                                             
{'error': 'invalid_request', 'error_description': 'Credentials in post body and basic Authorization header do not match'}                               
<Response [400]>  

My google account has more than 1 youtube account linked, maybe it is related to that.

LouisHrg commented 1 year ago

Hi, same issue with all my accounts, nothing is working atm

sigma67 commented 1 year ago

@LouisHrg do you also have more than 1 YouTube account linked to your Google account?

z3t4m4n commented 1 year ago

In my case, at one time you could have a YouTube account; before it was purchased by google. Later when they purchased and merged YouTube into the google ecosystem, you got to keep the old YouTube account if you wanted, and many did as its not wise to be commenting in YouTube with your real name, and keeping your old channel/uploads, So some people have more than one distinct YouTube accounts nested in a single google account.

knedl1k commented 11 months ago

Yeah same error here. Even if I do not use the OAuth method for private playlists I cannot log into the YT. image

sigma67 commented 11 months ago

Hi guys, I'm sorry that this is not working for you. This issue is account bound, so I'm unfortunately unable to help in this case.

Feel free to debug this further, the issue is probably related to the oauth functionality in ytmusicapi: https://github.com/sigma67/ytmusicapi/blob/master/ytmusicapi/auth/oauth.py

Check also here for more on how it works behind the scenes: https://github.com/sigma67/ytmusicapi/issues/10#issuecomment-1482498341

Perhaps you can find the issue by debugging with your account on the YouTube TV interface

Rexadev commented 11 months ago

@LouisHrg @z3t4m4n @knedl1k Try https://github.com/yogeshwaran01/spotify-playlist-to-youtube-playlist

sigma67 commented 8 months ago

This issue is too broad and there is no clear error cause, therefore I'm closing it

If you're having issues with oauth you can also use browser auth: https://ytmusicapi.readthedocs.io/en/stable/setup/index.html

The settings file to edit is at %APPDATA%\spotify_to_ytmusic on Windows, in ~/.cache on Linux

Daniel-GabrielN commented 1 month ago

I have encountered the same issue and solved it by deleting the second channel and then pasting the link https://www.google.com/device?user_code=XXXX-XXXX into a private window.