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

New Spotify Integration can't handle multiple account config #31666

Closed
BoneheadFraggle opened this issue Feb 9, 2020 · 13 comments
Closed

New Spotify Integration can't handle multiple account config #31666

BoneheadFraggle opened this issue Feb 9, 2020 · 13 comments
Assignees

Comments

@BoneheadFraggle
Copy link

BoneheadFraggle commented Feb 9, 2020

The problem

I have five Spotify accounts, all worked fine to integrate at the same time in the old integration.
After upgrading to 105.2, I changed the config and the Spotify Apps to the new syntax, and it works fine - but only for one account at a time.

The config won't allow several accounts specified at the same time. Or, I am doing it wrong and then I'd like to suggest an update of the documentation to make it easier to follow for multiple account config.

Environment

  • Home Assistant release with the issue: 105.2
  • Last working Home Assistant release (if known): 104.3
  • Operating environment (Hass.io/Docker/Windows/etc.): hass.io /Home Assistant
  • Integration causing this issue: Spotify
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/spotify/

Problem-relevant configuration.yaml

Old config that worked fine:

  - platform: spotify
    name: account_1
    client_id: !secret spotify_client_id_account_1
    client_secret: !secret spotify_client_secret_account_1
    cache_path: .spotify-token-cache-account_1

  - platform: spotify
    name: account_2
    client_id: !secret spotify_client_id_account_2
    client_secret: !secret spotify_client_secret_account_2
    cache_path: .spotify-token-cache-account_2

  - platform: spotify
    name: account_3
    client_id: !secret spotify_client_id_account_3
    client_secret: !secret spotify_client_secret_account_3
    cache_path: .spotify-token-cache-account_3

  - platform: spotify
    name: account_4
    client_id: !secret spotify_client_id_account_4
    client_secret: !secret spotify_client_secret_account_4
    cache_path: .spotify-token-cache-account_4

  - platform: spotify
    name: account_5
    client_id: !secret spotify_client_id_account_5
    client_secret: !secret spotify_client_secret_account_5
    cache_path: .spotify-token-cache-account_5

New config that works (only one account):

spotify:
  client_id: !secret spotify_client_id_account_1
  client_secret: !secret spotify_client_secret_account_1

But it won't accept more accounts.

Expected config would be something like this:

spotify:
- client_id: !secret spotify_client_id_account_1
  client_secret: !secret spotify_client_secret_account_1

- client_id: !secret spotify_client_id_account_2
  client_secret: !secret spotify_client_secret_account_2

...

Traceback/Error logs

Additional information

@dshokouhi
Copy link
Member

Use the integration screen instead of yaml it should work by just creating new entries there.

@BoneheadFraggle
Copy link
Author

Well, yes. But only for the "active" account, specified in configuration.yaml. I don't get any option to input next account's credentials or to choose which account to activate the integration for.

If I "edit client & client_secret to ..account_1" in configuration.yaml + restart + add the integration it works fine.

Then I can "edit client & client_secret to ..account_2" in configuration.yaml + restart + add the integration, then I get the second account's integration. And so on. But in a few minutes, the accounts not specified in the loaded configuration.yaml will time out and leave behind dead integrations.

Probably I'm just doing it wrong:
Can you show an example of a configuration.yaml that supports several Spotify accounts to be integrated?

@dshokouhi
Copy link
Member

You just create another integration, remove the yaml completely and keep adding new ones from configuration > integration. One for each account.

@probot-home-assistant
Copy link

Hey there @frenck, mind taking a look at this issue as its been labeled with a integration (spotify) you are listed as a codeowner for? Thanks!

@BoneheadFraggle
Copy link
Author

Ok, that sounds fine, but it doesn't work for me. The integration just add the already existing integration again. And if I press + again, It'll try to add the same account again.

When I had one integration active and working, I removed the yaml, restarted and tried to add a new integration - and then it says:
image

I'll remove the one that works and start over completely.

@BoneheadFraggle
Copy link
Author

New try, new server, no success:

Clean install, hass.io on Pi 3+

1. Following the documentation:
o create the required Spotify application:
• Login to Spotify Developer.
• Visit the My Applications page.
• Select Create An App. Enter any name and description.
• Once your application is created, view it and copy your Client ID and Client Secret, which are used in the Home Assistant configuration file.
• Add a Redirect URI in one of the following forms:
o If you are not using SSL: http://<your_home_assistant_url_or_local_ip>/auth/external/callback
• Click Save after adding the URI.

2. Add config
To add Spotify to your installation, add the following to your configuration.yaml file:

Example configuration.yaml entry

spotify:
client_id: YOUR_CLIENT_ID
client_secret: YOUR_CLIENT_SECRET

3. Restart HA
4. Got a new integration discovered after restart
image
5. Choose configure.
image

image

6. Back to HA
image

7. Add next account
image
image

image

8. Integration added - for the same account as above. No possibility to choose another account.
image

(User name blanked out).

I am still sure I do something wrong, but please describe where I do wrong so I can update the documentation.

@BoneheadFraggle
Copy link
Author

Found out why - something with the information being cached.
If I do this - it works.

  1. Basic setup from the documentation - setup the first account with integration
  2. Close the browser
  3. Prepare all other accounts with apps in Spotify (from the docs)
  4. Important - Open a new browser in Incognito mode
  5. Add a new Integration (+), choose Spotify
  6. Log in the user want to add
  7. Integration created.
  8. Close the browser.
    Repeat 4-8 for each account.

@km2000us
Copy link

@BoneheadFraggle Sorry to post this again after it has been closed.

I have managed to get 3 accounts to be available for integration following your instructions above.

However, after sometime, the first two accounts will present themselves as "unavailable" after some time. Only the last account whose client id that remains on configuration.yaml will remain available.

Have you come across the same problem or have found a resolution to the above problem?

@frenck
Copy link
Member

frenck commented Feb 20, 2020

However, after sometime, the first two accounts will present themselves as "unavailable" after some time. Only the last account whose client id that remains on configuration.yaml will remain available.

You should not add multiple entries to your configuration.yaml file. Only 1 entry (Spotify Application) goes into your configuration.yaml. You only need 1 application, which can be used for adding multiple accounts / instances via the Home Assistant frontend.

Adding in multiple to your configuration.yaml, will cause your accounts to expire.

@BoneheadFraggle
Copy link
Author

Just follow my steps and it should work.

  • Only add one account in configuration.yaml - step 1 / the docs.
  • For the other accounts, only add integrations (never change configuration.yaml).
  • I had to use Incognito mode in my browser AND close the browser between every new integration.

@km2000us
Copy link

Thanks @BoneheadFraggle and @frenck.

As you both pointed out, the correct way is to only add one client id and client secret once, and there no need to amend the configuration.yaml any more.

Instead of using incognito mode, I went to https://accounts.spotify.com and logged out after adding each intergration.

@Mucka911
Copy link

I cannot for the life of me add another account. I am prompted with two options when I got to auth. Configation.yaml or Home assistant cloud. I choose cloud and then choose my wife's login which is through Facebook, which might be an issue? anyways it spins and spins then aborts. I've tried incognito, different browser, nothing will get the other account to link I'm going mad.

@anthonyjacques20
Copy link

anthonyjacques20 commented Jun 11, 2022

@Mucka911 - I'm seeing the same thing. Tried via configuration.yaml and home assistant cloud, gone through all the steps in the documentation, forum posts, etc. I've tried incognito, logging out of Spotify everywhere, restarting home assistant, disabling/enabling the spotify integration, adding my wife to my spotify application, etc. The home assistant cloud gives me the spinning wheel and then appears to crash and give me the max retries errors. Doing it via the configuration.yaml gives me unknown error after going while redirecting back to my home assistant instance without providing any errors...

My wife's spotify login is via Facebook as well and I'm wondering if that is the culprit as well. Were you ever able to solve this problem?

Edit -> Confirmed that it wasn't the login via FB as I created another account with email/password and saw the same behavior...Anyone find any solutions to this?

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

No branches or pull requests

7 participants