FoxxMD / multi-scrobbler

Scrobble plays from multiple sources to multiple clients
https://foxxmd.github.io/multi-scrobbler
MIT License
398 stars 17 forks source link

Last.fm auth not working #32

Closed Syco54645 closed 3 years ago

Syco54645 commented 3 years ago

I posted this on the unraid forum but will post here as well for better visibility.

Trying to get this setup and working and having issues with the last.fm client. It is telling me "Status: Auth Interaction Required". When I click the link to (re)authenticate or initialize I get various forms of failure. I have created an API key and put the values in to the config.json. I am unsure of how it should function when I get passed to lastfm and then back to the server http://tower.local:9078//lastfm/callback?state=FrankLFM&token=XXXXXXXXXXXX

At this point the page says OK and that is it. Heading back to the application it still says that last.fm is not authenticated. Any idea what I am missing?

2021-09-28T09:33:10-04:00 info : [App ] Server started at http://localhost:9078
2021-09-28T09:33:10-04:00 info : [Sources ] (partyPlex) plex source initialized
2021-09-28T09:33:10-04:00 info : [Source - Plex - partyPlex] Initializing with the following filters => Users: N/A | Libraries: party | Servers: N/A
2021-09-28T09:33:10-04:00 info : [Sources ] (FrankPlex) plex source initialized
2021-09-28T09:33:10-04:00 info : [Source - Plex - FrankPlex] Initializing with the following filters => Users: frank | Libraries: N/A | Servers: N/A
2021-09-28T09:33:10-04:00 warn : [Scrobblers ] (FrankLFM) lastfm client auth failed.
2021-09-28T09:33:10-04:00 error : [Client Lastfm - FrankLFM] Error: Invalid session key - Please re-authenticate
at CWD/node_modules/lastfm-node-client/lib/ApiRequest.js:136:11 at processTicksAndRejections (internal/process/task_queues.js:95:5) at async LastfmApiClient.callApi (file://CWD/apis/LastfmApiClient.js:84:20) at async LastfmApiClient.testAuth (file://CWD/apis/LastfmApiClient.js:148:30) at async LastfmScrobbler.testAuth (file://CWD/clients/LastfmScrobbler.js:34:27) at async ScrobbleClients.addClient (file://CWD/clients/ScrobbleClients.js:240:27) at async ScrobbleClients.buildClientsFromConfig (file://CWD/clients/ScrobbleClients.js:195:17) at async file://CWD/index.js:128:9 2021-09-28T09:33:10-04:00 error : [Client Lastfm - FrankLFM] Could not successfully communicate with Last.fm API
2021-09-28T09:33:10-04:00 error : [API - Lastfm - FrankLFM] Testing auth failed
2021-09-28T09:33:10-04:00 info : [Scrobblers] (FrankLFM) lastfm client initialized
FoxxMD commented 3 years ago

Thanks for creating an issue here and thanks for providing logs!

From your logs it looks like either you or multi-scrobbler is providing an invalid session value. This is most likely because your configuration is incorrect. Please check these things:

Key and Secret are provided in your config

Ensure that you are providing the API Key and Secret you received from registering your last.fm application correctly. The json for the last data in your config should look like this:

{
  "apiKey": "879c9206k14g450a2a2eb42320831ab3",
  "secret": "ce24e90d3v7vb40sdg61ac141607266c",
  "redirectUri": "http://YOURIP:9078/lastfm/callback"
}

Note: If you are doing the normal, initial setup you should not include the session property in this data. This is handled by multi-scrobbler. If you have session included in any way (even as an empty string) this could be the issue.

Ensure your callback URL is correct

redirectUri is the URL that last.fm will redirect your browser to after initial authentication is complete (after going through (re)authenticate or initialize process). http://YOURIP:9078 from the example should be replaced by where you actually find multi-scrobbler -- presumably http://tower.local:9078. If this isn't correct then the authentication process cannot be completed.

Note: This need to be exactly the same in both the config and what you set when creating the last.fm api key

Delete any existing credentials created by multi-scrobbler

multi-scrobbler saves the session value from a complete authentication for convenience. It's possible (but not likely) that the value it has is outdated/incorrect. This could happen if you updated an existing last.fm api key or created a new one after trying to authenticate with another key. In the same folder where your config.json is located delete any files with similar names to currentCreds-lastfm-FrankLFM.json


Hopefully one of those things will fix your issue. P.S. on github you should triple backticks when pasting lots of text/code rather than using single backticks.

Syco54645 commented 3 years ago

Hello and thank you for the response. I should have made it clear that I am running this in unraid via a container. I have created another api and made sure that the redirectUri matches what was entered in to last.fm when creating the api. It still does not appear to be working. Would multi-scrobbler modify the config.json file (if so perhaps it is a permission issue)?

Pasting my config with the important bits removed as it has to be something quite simple that I am missing somewhere.

{
    "sourceDefaults": {
      "maxPollRetries": 0,
      "maxRequestRetries": 1,
      "retryMultiplier": 1.5
    },
    "clientDefaults": {
      "maxRequestRetries": 1,
      "retryMultiplier": 1.5
    },
    "sources": [
      {
        "type": "plex",
        "name": "FrankPlex",
        "clients": ["FrankLFM"],
        "data": {
          "user": ["Frank"]
        }
      },
      {
        "type": "plex",
        "name": "partyPlex",
        "data": {
          "user": ["Jukebox"]
        }
      }
    ],
    "clients": [
      {
        "type": "lastfm",
        "name": "FrankLFM",
        "data": {
          "apiKey": "apiKeyRedacted",
          "secret": "secretKeyRedacted",
          "redirectUri": "http://SERVERURL:9078/lastfm/callback"
        }
      }
    ]
  }

I use local dnsmasq and have tried both the local url and the ip address for the server url, creating a different api on last.fm each time.

Syco54645 commented 3 years ago

So I just restarted and now it is working, at least as much as auth is concerned. The only thing I changed was I noticed that the partyPlex did not have a user defined and was pointing to a library that I did not actually have. I reverted that and am unable to produce the same failure. I am unsure why it is working now. I can help if you want to try to debug this further and see why it was not working correctly in case there is something causing this to happen that looks unrelated.

FoxxMD commented 3 years ago

Turning it off and then back on again fixes everything :upside_down_face: glad its working now. That gives me a good hint as to why it might not be working (potentially not parsing retrieved session id on first setup?).

For now I'd call this case closed. If you experience this happening again please let me know. When I have some time to work on MS i'll check this out as well.