[GH-ISSUE #228] Please clarify the setup documentation #178

Closed
opened 2026-02-27 22:08:27 +03:00 by kerem · 7 comments
Owner

Originally created by @salsaman on GitHub (Sep 26, 2021).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/228

Hi, I have been struggling to get thius set up,, and am not finding the setup instructions very helpful.
Please can you clarify what the general forrmat of the request headers text and the 'cookie' should look like.. I have gone through the steps best as I can make out, but when I try to use the cookie (?) in Home Assistant, I keep getting an error teeling me it is unable to connect.. Without clearer exemples to follow, I cannot be sure if the issue is with Home Assistant integration or with the text which I am pasting in the Cookie field.

Originally created by @salsaman on GitHub (Sep 26, 2021). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/228 Hi, I have been struggling to get thius set up,, and am not finding the setup instructions very helpful. Please can you clarify what the general forrmat of the request headers text and the 'cookie' should look like.. I have gone through the steps best as I can make out, but when I try to use the cookie (?) in Home Assistant, I keep getting an error teeling me it is unable to connect.. Without clearer exemples to follow, I cannot be sure if the issue is with Home Assistant integration or with the text which I am pasting in the Cookie field.
kerem closed this issue 2026-02-27 22:08:28 +03:00
Author
Owner

@sigma67 commented on GitHub (Sep 26, 2021):

Hi, please refer to the documentation to point out where exactly it is unclear: https://ytmusicapi.readthedocs.io/en/latest/setup.html

For Home Assistant, please refer to https://github.com/KoljaWindeler/ytube_music_player/

<!-- gh-comment-id:927261237 --> @sigma67 commented on GitHub (Sep 26, 2021): Hi, please refer to the documentation to point out where exactly it is unclear: https://ytmusicapi.readthedocs.io/en/latest/setup.html For Home Assistant, please refer to https://github.com/KoljaWindeler/ytube_music_player/
Author
Owner

@salsaman commented on GitHub (Sep 26, 2021):

The problem I am having is this - when I try to do the setup in Home Assistant, there is a text field where I am supposed to enter the cookie text. I followed the instructions and opened dev tools, searched for /browse and found the request headers. Amongst the headers, there is a "Cookie" field. I copied the value into the HA setup, and it came back with an error, "Something with your cookie wasn't right. Format and fields are ok but the login failed:." So then returning to the documentation, I see "Using the headers in your project". Thus, I figured maybe I had to follow the instructions and process the headers using a python console, and paste in the resulting output. I tried this, and again received the same error in HA. So then I began to question exactly what I was supposed to cut and paste.
Since there was no example of what the cookie data is supposed to look like, I cannot tell if I am pasting in the necessary data or not. The cookie data I have begins with "VISITOR_INFO1_LIVE=...:" and then contains several other pieces of data separated with ";" ending with "__Secure-3PSIDCC=...". It is not clear if I should paste in all of this, or if in fact I do need to run the python console commands and paste in the resulting output. Anyway, neither worked for me, I continue to get the same error. Since there are no examples of what the cookie data is supposed to look like, I have no way of telling if the problem is with the data returned from the browser, or if the problem is with the HA setup. Including an example of what the cookie data should look like would be useful to try to troubleshoot this issue. Frustratingly, the part of the documentation where it would be sensible to provide an example, ie. the file fields, the text simply says "PASTE_COOKIE". Not very helpful in this instance.
I am rasing the issue here, because in ytube_msuci_player, it simply suggests referring to the documentation here.

<!-- gh-comment-id:927316674 --> @salsaman commented on GitHub (Sep 26, 2021): The problem I am having is this - when I try to do the setup in Home Assistant, there is a text field where I am supposed to enter the cookie text. I followed the instructions and opened dev tools, searched for /browse and found the request headers. Amongst the headers, there is a "Cookie" field. I copied the value into the HA setup, and it came back with an error, "Something with your cookie wasn't right. Format and fields are ok but the login failed:." So then returning to the documentation, I see "Using the headers in your project". Thus, I figured maybe I had to follow the instructions and process the headers using a python console, and paste in the resulting output. I tried this, and again received the same error in HA. So then I began to question exactly what I was supposed to cut and paste. Since there was no example of what the cookie data is supposed to look like, I cannot tell if I am pasting in the necessary data or not. The cookie data I have begins with "VISITOR_INFO1_LIVE=...:" and then contains several other pieces of data separated with ";" ending with "__Secure-3PSIDCC=...". It is not clear if I should paste in all of this, or if in fact I do need to run the python console commands and paste in the resulting output. Anyway, neither worked for me, I continue to get the same error. Since there are no examples of what the cookie data is supposed to look like, I have no way of telling if the problem is with the data returned from the browser, or if the problem is with the HA setup. Including an example of what the cookie data should look like would be useful to try to troubleshoot this issue. Frustratingly, the part of the documentation where it would be sensible to provide an example, ie. the file fields, the text simply says "PASTE_COOKIE". Not very helpful in this instance. I am rasing the issue here, because in ytube_msuci_player, it simply suggests referring to the documentation here.
Author
Owner

@salsaman commented on GitHub (Sep 26, 2021):

Checking logs in Homea Assistent I see the following:

2021-09-26 15:34:59 ERROR (MainThread) [custom_components.ytube_music_player.config_flow] Traceback (most recent call last):
File "/config/custom_components/ytube_music_player/config_flow.py", line 188, in async_check_data
YTMusic.setup(filepath = user_input[CONF_HEADER_PATH], headers_raw = c)
File "/usr/local/lib/python3.9/site-packages/ytmusicapi/ytmusic.py", line 156, in setup
return setup(filepath, headers_raw)
File "/usr/local/lib/python3.9/site-packages/ytmusicapi/setup.py", line 36, in setup
raise Exception(
Exception: The following entries are missing in your headers: cookie, x-goog-authuser. Please try a different request (such as /browse) and make sure you are logged in.

However, that field does exist in the cookie text, ie:
"x-goog-authuser": "0",

I can confirm this was copied from a /browse request and I am logged in.
I do have a field x-goog-visitor-id, with non-zero data, so maybe Google has updated the request headers in some way ?
Or perhaps it has something to do with 2-step authorization which I do have enabled ?

<!-- gh-comment-id:927350679 --> @salsaman commented on GitHub (Sep 26, 2021): Checking logs in Homea Assistent I see the following: 2021-09-26 15:34:59 ERROR (MainThread) [custom_components.ytube_music_player.config_flow] Traceback (most recent call last): File "/config/custom_components/ytube_music_player/config_flow.py", line 188, in async_check_data YTMusic.setup(filepath = user_input[CONF_HEADER_PATH], headers_raw = c) File "/usr/local/lib/python3.9/site-packages/ytmusicapi/ytmusic.py", line 156, in setup return setup(filepath, headers_raw) File "/usr/local/lib/python3.9/site-packages/ytmusicapi/setup.py", line 36, in setup raise Exception( Exception: The following entries are missing in your headers: cookie, x-goog-authuser. Please try a different request (such as /browse) and make sure you are logged in. However, that field does exist in the cookie text, ie: "x-goog-authuser": "0", I can confirm this was copied from a /browse request and I am logged in. I do have a field x-goog-visitor-id, with non-zero data, so maybe Google has updated the request headers in some way ? Or perhaps it has something to do with 2-step authorization which I do have enabled ?
Author
Owner

@sigma67 commented on GitHub (Oct 3, 2021):

If you want me to check your cookie you can send it to ytmusicapi@gmail.com, maybe I can find the issue

<!-- gh-comment-id:932940314 --> @sigma67 commented on GitHub (Oct 3, 2021): If you want me to check your cookie you can send it to ytmusicapi@gmail.com, maybe I can find the issue
Author
Owner

@khmikkelsen commented on GitHub (Oct 18, 2021):

The problem I am having is this - when I try to do the setup in Home Assistant, there is a text field where I am supposed to enter the cookie text. I followed the instructions and opened dev tools, searched for /browse and found the request headers. Amongst the headers, there is a "Cookie" field. I copied the value into the HA setup, and it came back with an error, "Something with your cookie wasn't right. Format and fields are ok but the login failed:." So then returning to the documentation, I see "Using the headers in your project". Thus, I figured maybe I had to follow the instructions and process the headers using a python console, and paste in the resulting output. I tried this, and again received the same error in HA. So then I began to question exactly what I was supposed to cut and paste. Since there was no example of what the cookie data is supposed to look like, I cannot tell if I am pasting in the necessary data or not. The cookie data I have begins with "VISITOR_INFO1_LIVE=...:" and then contains several other pieces of data separated with ";" ending with "__Secure-3PSIDCC=...". It is not clear if I should paste in all of this, or if in fact I do need to run the python console commands and paste in the resulting output. Anyway, neither worked for me, I continue to get the same error. Since there are no examples of what the cookie data is supposed to look like, I have no way of telling if the problem is with the data returned from the browser, or if the problem is with the HA setup. Including an example of what the cookie data should look like would be useful to try to troubleshoot this issue. Frustratingly, the part of the documentation where it would be sensible to provide an example, ie. the file fields, the text simply says "PASTE_COOKIE". Not very helpful in this instance. I am rasing the issue here, because in ytube_msuci_player, it simply suggests referring to the documentation here.

The way I got around this issue in HA is by running the package through my normal python development environment, and just copy pasting the output from ytmusicapi.

<!-- gh-comment-id:945623417 --> @khmikkelsen commented on GitHub (Oct 18, 2021): > The problem I am having is this - when I try to do the setup in Home Assistant, there is a text field where I am supposed to enter the cookie text. I followed the instructions and opened dev tools, searched for /browse and found the request headers. Amongst the headers, there is a "Cookie" field. I copied the value into the HA setup, and it came back with an error, "Something with your cookie wasn't right. Format and fields are ok but the login failed:." So then returning to the documentation, I see "Using the headers in your project". Thus, I figured maybe I had to follow the instructions and process the headers using a python console, and paste in the resulting output. I tried this, and again received the same error in HA. So then I began to question exactly what I was supposed to cut and paste. Since there was no example of what the cookie data is supposed to look like, I cannot tell if I am pasting in the necessary data or not. The cookie data I have begins with "VISITOR_INFO1_LIVE=...:" and then contains several other pieces of data separated with ";" ending with "__Secure-3PSIDCC=...". It is not clear if I should paste in all of this, or if in fact I do need to run the python console commands and paste in the resulting output. Anyway, neither worked for me, I continue to get the same error. Since there are no examples of what the cookie data is supposed to look like, I have no way of telling if the problem is with the data returned from the browser, or if the problem is with the HA setup. Including an example of what the cookie data should look like would be useful to try to troubleshoot this issue. Frustratingly, the part of the documentation where it would be sensible to provide an example, ie. the file fields, the text simply says "PASTE_COOKIE". Not very helpful in this instance. I am rasing the issue here, because in ytube_msuci_player, it simply suggests referring to the documentation here. The way I got around this issue in HA is by running the package through my normal python development environment, and just copy pasting the output from ytmusicapi.
Author
Owner

@salsaman commented on GitHub (Oct 29, 2021):

Can this really be closed ? The suggested solution above would be troublesmoe for me as I do not have the development environment set up, a not uncommon case, I would imagine. Without going through the instaltion process to get a development envirnment set up, I cannot confirm whether or no the suggestion above would work in my case, as it does seem likely that the problem is the format of the cookie, which lacks the specific field mentioned.

I apologise for not emailing the cookie, as I am right in the middle of moving home and overseeing the large scal refurbishment taking place there. As soon as I get a free hour I will forward it. Closing this without offering a more convenient solution which doesn't require installing a complete dev. environment seems a little premature to me.

<!-- gh-comment-id:954403539 --> @salsaman commented on GitHub (Oct 29, 2021): Can this really be closed ? The suggested solution above would be troublesmoe for me as I do not have the development environment set up, a not uncommon case, I would imagine. Without going through the instaltion process to get a development envirnment set up, I cannot confirm whether or no the suggestion above would work in my case, as it does seem likely that the problem is the format of the cookie, which lacks the specific field mentioned. I apologise for not emailing the cookie, as I am right in the middle of moving home and overseeing the large scal refurbishment taking place there. As soon as I get a free hour I will forward it. Closing this without offering a more convenient solution which doesn't require installing a complete dev. environment seems a little premature to me.
Author
Owner

@khmikkelsen commented on GitHub (Oct 29, 2021):

This is not a ytmusicapi issue, it's a HA issue not being able to use the console.
You could probably get around this connecting to your HA through SSH, then running ytmusicapi. However, it's really not much trouble to install python and running a small script once. You could always create an additional argument in the YTMusic with a path, which then reads a file, and make a pull request :)

<!-- gh-comment-id:954572099 --> @khmikkelsen commented on GitHub (Oct 29, 2021): This is not a ytmusicapi issue, it's a HA issue not being able to use the console. You could probably get around this connecting to your HA through SSH, then running ytmusicapi. However, it's really not much trouble to install python and running a small script once. You could always create an additional argument in the YTMusic with a path, which then reads a file, and make a pull request :)
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/ytmusicapi#178
No description provided.