Yooooomi / your_spotify

Self hosted Spotify tracking dashboard
GNU General Public License v3.0
3.13k stars 126 forks source link

Unable to auth Spotify #65

Closed Bastilms closed 2 years ago

Bastilms commented 2 years ago

Hey,

I have a few issues with the API. When I try to connect my Spotify, I get redirected to https://<my domain>.de//oauth/spotify. I'm not sure why it uses the two //. However, I fix it by deleting on. After this, I get redirected to the Spotify API. Unfortunately, the next error INVALID_CLIENT: Invalid redirect URI. The reason for this is the following part in the URL: &redirect_uri=https%3A%2F%2F<my domain>%2Foauth%2Fspotify%2Fcallback%2Foauth%2Fspotify%2Fcallback. I Also solved this by deleting the last %2Foauth%2Fspotify%2Fcallback because it didn't make that much sense to me. After the next redirect, I'm back on my server's API with a 401 Error on the following URL: https://<my domain>/oauth/spotify/callback?code=<Authorized Key>. Now I'm stuck and not quite sure why this happens.

    spotify_app:
      image: yooooomi/your_spotify_server
      container_name: express-mongo
      restart: always
      ports:
        - "8080:8080"
      links:
        - mongo
      depends_on:
        - mongo
      environment:
        - API_ENDPOINT=https://<my domain>/oauth/spotify/callback # This MUST be included as a valid URL in the spotify dashboard
        - CLIENT_ENDPOINT=http://smarthome.home:3005
        - SPOTIFY_PUBLIC=<Public>
        - SPOTIFY_SECRET=<Secret>
          #- CORS=http://smarthome.home:3005,http://localhost:3006
        - CORS=all
          #- MONGO_ENDPOINT=mongodb://mongo:27017/your_spotify

    mongo:
      container_name: spotify_mongo
      image: mongo
      volumes:
        - /root/ipmi2mqtt/spotify//your_spotify_db:/data/db

    spotify_web:
      image: yooooomi/your_spotify_client
      container_name: spotify_web
      restart: always
      ports:
        - "3005:3000"
      environment:
        - API_ENDPOINT=https://<my domain>/

Does anyone have a solution? Maybe it's because I'm using an internal domain to access the Dashboard, and only the API is on a public domain.

tansionline commented 2 years ago

Hey, first can you hide your SPOTIFY_SECRET key. Its must be secret, but you shared it here 😄 . Did you register in spotify dashboard your redirect URL? Must be something like that: ( Edit Settings inside )

Screen Shot 2022-01-13 at 11 42 38
Bastilms commented 2 years ago

Hey, yes, I added the redirect URL already to the Spotify dashboard. Spotify

Bastilms commented 2 years ago

Nevermind! I deleted the last part of the redirect URL inside my docker compose file (/oauth/spotify/callback). Now it works fine. I Still don't know why I have these two // when I try to connect my Spotify for the first time. Maybe I have still a typo. Who knows. My Problem is now solved

I get redirected to https://<my domain>.de//oauth/spotify. I'm not sure why it uses the two //. However, I fix it by deleting on.

just5ky commented 2 years ago

I am also facing the issue with https://spotapi.DOMAIN//oauth/spotify when I try to authorize.

image

I have to manually remove one / to be able to continue

My compose

  spotify_server:
    image: yooooomi/your_spotify_server
    container_name: spotify_server
    restart: always
    ports:
      - "5555:8080"  #https://spotapi.DOMAIN.eu/
    links:
      - mongo
    depends_on:
      - mongo
    environment:
      - API_ENDPOINT=https://spotapi.DOMAIN.eu # This MUST be included as a valid URL in the spotify dashboard
      - CLIENT_ENDPOINT=https://spotify.justsky.eu
      - SPOTIFY_PUBLIC=$SPOTIFY_KEY
      - SPOTIFY_SECRET=$SPOTIFY_SECRET
      - CORS=all
      - MONGO_ENDPOINT=mongodb://spotify_mongo:27017/your_spotify

  mongo:
    container_name: spotify_mongo
    image: arm64v8/mongo:4.4
    restart: always
    volumes:
      - $DOCKERDIR/your_spotify_db:/data/db

  spotify_web:
    image: yooooomi/your_spotify_client
    container_name: spotify_web
    restart: always
    ports:
      - "3003:3000"   #https://spotify.DOMAIN.eu
    environment:
      - API_ENDPOINT=https://spotapi.DOMAIN.eu

I was not sure which domain to add, so I added both image

Rest everything works, just waiting for axios and npm update.