extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[Spotify Player] I am always required to sign in

Open sajeezy opened this issue 2 years ago • 22 comments

Extension

https://www.raycast.com/mattisssa/spotify-player

Description

Everytime I try to use a command, it requires me to sign in. CleanShot 2024-01-04 at 18 15 48

Steps To Reproduce

Download extension Log in (authenticate) Approve Done Next time i need to use command, it asks to authenticate again

Current Behaviour

No response

Expected Behaviour

No response

sajeezy avatar Jan 04 '24 18:01 sajeezy

Thank you for opening this issue!

🔔 @mattisssa @peduarte @sxn @dillionverma @andreaselia @stuart @tonka3000 @dancannon @pernielsentikaer @stevensd2m @erics118 @hjoelh @hobhouse @bkeys818 @jatindotdev you might want to have a look.

💡 Author and Contributors commands

The author and contributors of mattisssa/spotify-player can trigger bot actions by commenting:

  • @raycastbot close this issue Closes the issue.
  • @raycastbot rename this issue to "Awesome new title" Renames the issue.
  • @raycastbot reopen this issue Reopen the issue.

raycastbot avatar Jan 04 '24 18:01 raycastbot

I have that same issue and it's annoying.

bokamix avatar Jan 24 '24 09:01 bokamix

Hey, can you provide more details please? Steps to reproduce and/or a video recording? We are unable to reproduce.

peduarte avatar Jan 30 '24 14:01 peduarte

Hey, can you provide more details please? Steps to reproduce and/or a video recording? We are unable to reproduce.

I have been using the plugin the last four days and it required me to sign-in 5 Times already... I'm normally using my Mac and not touching anything related to the Plugin, however the red Cautionmark still pops up after a while image

This is the Error, I am getting:

{"_isRayError":true,"code":16,"title":"Could not initialize OAuth","name":"Error","message":"OAuth request creation is not available when command is launched in background","stack":"Error: OAuth request creation is not available when command is launched in background\n    at Rr (/Applications/Raycast.app/Contents/Resources/RaycastCommands_RaycastCommands.bundle/Contents/Resources/api/node_modules/@raycast/server/index.js:25:230)\n    at Ye (/Applications/Raycast.app/Contents/Resources/RaycastCommands_RaycastCommands.bundle/Contents/Resources/api/node_modules/@raycast/server/index.js:24:6249)\n    at ht (/Applications/Raycast.app/Contents/Resources/RaycastCommands_RaycastCommands.bundle/Contents/Resources/api/node_modules/@raycast/server/index.js:24:6374)\n    at Immediate.<anonymous> (/Applications/Raycast.app/Contents/Resources/RaycastCommands_RaycastCommands.bundle/Contents/Resources/api/node_modules/@raycast/server/index.js:24:6139)\n    at process.processImmediate (node:internal/timers:478:21)","breadcrumbs":[{"level":"debug","category":"Request","message":"","timestamp":"2024-02-02T15:51:37.828Z","data":{"function":"getApplications"}}]}: 

(Sorry for bad formatting :D)

Evolinox avatar Feb 02 '24 15:02 Evolinox

Oh ok, that's certainly not expected behaviour :/ is there anything else you could share, perhaps whether you're using a vpn?

@sxn can you think of any reason why this may happen to this specific user?

peduarte avatar Feb 03 '24 08:02 peduarte

not sure 🤔 @Evolinox what version of Raycast are you using? and – did the menu bar command work after you logged in? could you see the currently playing song for a while, only to then later have it stop working?

sxn avatar Feb 03 '24 17:02 sxn

Oh ok, that's certainly not expected behaviour :/ is there anything else you could share, perhaps whether you're using a vpn?

@sxn can you think of any reason why this may happen to this specific user?

Can't share much more, i think :/ I didn't use a VPN at all.

not sure 🤔 @Evolinox what version of Raycast are you using? and – did the menu bar command work after you logged in? could you see the currently playing song for a while, only to then later have it stop working?

I am currently using Version 1.66.2. The Menubar Command works fine for atleast an hour... when i come back to my Mac, it has logged out and displays the red danger icon. Maybe it has to do with the Standby Mode?

Evolinox avatar Feb 04 '24 09:02 Evolinox

I know that sometimes when I login after my laptop's been asleep, i see the reed triangle too while it's connecting to the wifi. but once it connects, it goes away and I dont need to sign in again. fwiw ive been using this extension for months. so this is so weird.

have you tried uninstalling the extension and installing it again?

peduarte avatar Feb 04 '24 17:02 peduarte

Just wanted to circle back here. I travelled to a country where the Spotify service is not available – I could still use Spotify on my devices though, but the extension was forcing me to sign in. I have since returned to South Africa and its not caused me problems yet. So I will monitor it this week and report back.

sajeezy avatar Feb 05 '24 11:02 sajeezy

have you tried uninstalling the extension and installing it again?

Yes, ive done this twice already, but its still happening.

I travelled to a country where the Spotify service is not available – I could still use Spotify on my devices though, but the extension was forcing me to sign in.

I'm from/in Germany, where Spotify is fully available afaik.

Evolinox avatar Feb 12 '24 15:02 Evolinox

Same on my end unfortunately

cupcakearmy avatar Mar 19 '24 15:03 cupcakearmy

Same here. Anyone working on this?

dch09 avatar Mar 21 '24 09:03 dch09

I’ve noticed that it stays signed in if I enable “Hide icon when idle” in the settings for Menu Bar Player. It might be something to do with Oauth not being able to make requests in the background.

alivault avatar Mar 21 '24 18:03 alivault

I retract my previous comment. "Hide icon when idle" doesn't seem to make a difference; the extension continues to log out at least once a day.

alivault avatar Mar 24 '24 23:03 alivault

Yeah, have the same issue.

flawnn avatar Mar 31 '24 13:03 flawnn

I’ve noticed that it stays signed in if I enable “Hide icon when idle” in the settings for Menu Bar Player. It might be something to do with Oauth not being able to make requests in the background.

For me... it seemed to resolve it. Since I disabled the "mane bar player" in the settings completely I've stayed logged in

cupcakearmy avatar Apr 03 '24 14:04 cupcakearmy

https://github.com/raycast/extensions/tree/4367e1f447712d070bfe44e5f2b9d4ad5b408cac/extensions/spotify-player/

This version works perfectly for me. Installed it locally and with the menu bar player everything works fine. There must be something broken in between then with the OAuth Configuration and the menu bar player.

flawnn avatar Apr 03 '24 18:04 flawnn

same issue here 👍🏻

Joshua-Wilcox avatar Apr 12 '24 17:04 Joshua-Wilcox

Deactivating the menu bar player seems to solve the signing out problem.

alivault avatar Apr 12 '24 17:04 alivault

any fixes to use the menu bar player?

lucasmpramos avatar May 07 '24 18:05 lucasmpramos

any fixes to use the menu bar player?

Nope, it still happens

Evolinox avatar May 19 '24 10:05 Evolinox

This issue has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 10 days to keep our backlog clean 😊

raycastbot avatar Jul 08 '24 11:07 raycastbot

There is nothing to close here - This is still an issue. Please DON'T CLOSE!

flawnn avatar Jul 14 '24 14:07 flawnn

No updates here guys?

I know this is non-profit. But this has been an issue for months now. Isn't it relatively easy to fix?

Such a nice little feature – like everything else Raycast.

Please fix

lucasmpramos avatar Jul 18 '24 17:07 lucasmpramos

Getting a similar issue. Commenting to follow, this has never happened until a week or so ago

ewega avatar Sep 05 '24 21:09 ewega

I've noticed the same behavior for the past couple of weeks, but I'm not sure if it's connected to the extension 🤔

mattisssa avatar Sep 16 '24 09:09 mattisssa

I am playing around with modifying the setSpotifyClient function to include a network check and retry logic. Rebuilt the plugin and installed it. It's been 24 hours and the plugin hasn't lost its (freshly authorized) Oauth token, so we'll see if this continues. FWIW this was a quick hack and this is most def not implemented ideally! BTW the menu bar is enabled and working which was problematic before. Waiting for it to ask for Spotify auth again tho. lolz

import { showHUD } from "@raycast/api";

export async function setSpotifyClient() {
  const isConnected = await checkNetworkConnectivity();
  if (!isConnected) {
    await showHUD("Network is not available. Please check your VPN connection.");
    return;
  }

  let retries = 3;
  while (retries > 0) {
    try {
      const accessToken = await provider.authorize();
      api.defaults.headers = {
        Authorization: `Bearer ${accessToken}`,
      };
      api.defaults.fetch = nodeFetch as any;
      spotifyClient = api;
      return;
    } catch (error) {
      console.error("Error during authentication:", error);
      retries--;
      if (retries === 0) {
        await showHUD("Failed to authenticate with Spotify. Please try again.");
        throw error;
      }
      await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds before retrying
    }
  }
}

async function checkNetworkConnectivity() {
  try {
    await fetch('https://api.spotify.com', { method: 'HEAD', mode: 'no-cors' });
    return true;
  } catch (error) {
    return false;
  }
}

24 Hour Update: It’s still working. Whatever I did seems to be holding up, although it looks like I have the extension installed twice (probably the local dev version and the original one I installed). In the settings, the Raycast version shows two Spotify login buttons, while the dev version only has one. Screenshot 2024-10-10 at 12 42 29 PM Screenshot 2024-10-10 at 12 42 32 PM

danielraffel avatar Oct 09 '24 18:10 danielraffel

I am playing around with modifying the setSpotifyClient function to include a network check and retry logic. Rebuilt the plugin and installed it. It's been 24 hours and the plugin hasn't lost its (freshly authorized) Oauth token, so we'll see if this continues. FWIW this was a quick hack and this is most def not implemented ideally! BTW the menu bar is enabled and working which was problematic before. Waiting for it to ask for Spotify auth again tho. lolz

import { showHUD } from "@raycast/api";

export async function setSpotifyClient() {
  const isConnected = await checkNetworkConnectivity();
  if (!isConnected) {
    await showHUD("Network is not available. Please check your VPN connection.");
    return;
  }

  let retries = 3;
  while (retries > 0) {
    try {
      const accessToken = await provider.authorize();
      api.defaults.headers = {
        Authorization: `Bearer ${accessToken}`,
      };
      api.defaults.fetch = nodeFetch as any;
      spotifyClient = api;
      return;
    } catch (error) {
      console.error("Error during authentication:", error);
      retries--;
      if (retries === 0) {
        await showHUD("Failed to authenticate with Spotify. Please try again.");
        throw error;
      }
      await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds before retrying
    }
  }
}

async function checkNetworkConnectivity() {
  try {
    await fetch('https://api.spotify.com', { method: 'HEAD', mode: 'no-cors' });
    return true;
  } catch (error) {
    return false;
  }
}

24 Hour Update: It’s still working. Whatever I did seems to be holding up, although it looks like I have the extension installed twice (probably the local dev version and the original one I installed). In the settings, the Raycast version shows two Spotify login buttons, while the dev version only has one. Screenshot 2024-10-10 at 12 42 29 PM Screenshot 2024-10-10 at 12 42 32 PM

I'd say go for the PR to fix this finally?

flawnn avatar Oct 19 '24 21:10 flawnn

Are there any updates on a fix for this? I just linked a number of related issues, this still seems to be an ongoing problem for many (including myself)

elstgav avatar Oct 31 '25 18:10 elstgav