jbszczepaniak / spotify-cli

Terminal client for Spotify
MIT License
176 stars 10 forks source link

invalid_client returned when authenticating #6

Closed lbatalha closed 4 years ago

lbatalha commented 5 years ago

When authenticating for the first time the end result is:


Response: {"error":"invalid_client","error_description":"Invalid client"}```

To reproduce:
- Have Spotify Premium
- Create new App in developer portal
- Setup Callback url to `http://localhost:8888/spotify-cli` and apply
- Build `spotify-cli` from latest sources on MacOS
- Launch with `SPOTIFY_CLIENT=MYCLIENTID SPOTIFY_SECRET=MYSECRET spotify-cli`
- Chrome page opens with OAUTH page, accept it
- Error appears
jbszczepaniak commented 5 years ago

Error appears in console or in browser?

jbszczepaniak commented 5 years ago

I changed README, please try to install with steps provided there.

lbatalha commented 5 years ago

Running the pre-built version doesnt work at all, I had to build it myself from master, which at least gets me to the error response.

Can you try setting up a new application?

Also the URL you have does not appear to be correct (but it does redirect to the correct one) The current one seems to be https://developer.spotify.com/dashboard/applications

jbszczepaniak commented 5 years ago

Actually I tried and it worked for me, it looks that our environment differs somehow. Which release did you download, and how it didn't work?

lbatalha commented 5 years ago

Setup: MacOS High Sierra (latest update)

Steps:

goroutine 1 [running]: main.main() /Users/jedrzejszczepaniak/go/src/github.com/jedruniu/spotify-cli/main.go:100 +0x555 zsh: exit 2 SPOTIFY_CLIENT_ID=76** SPOTIFY_SECRET= spotify-cl



With app built from `master`, I get the original error in the first post.

Also, how does your app save state, if I run the source built one with same tokens it just gives me invalid token
jbszczepaniak commented 5 years ago

How come you have my surname and name in traceback? `/Users/jedrzejszczepaniak/go

jbszczepaniak commented 5 years ago

It's not in the code

jbszczepaniak commented 5 years ago

About state it is regenerated each time application starts

lbatalha commented 5 years ago

I don't know why that error message has your local FS stuff, I'd assume its something Go does when building.

snippins commented 5 years ago

Based on the error messages, this is basically issue #1.

jbszczepaniak commented 5 years ago

@snippins @lbatalha If you want to correct the bug - I will be glad to accept merge request.

ideologysec commented 5 years ago

Same issue on macOS 10.14.4

$ go version
go version go1.12.4 darwin/amd64

and I get a log result that looks like this:

server.go:2979: http: panic serving [::1]:58356: runtime error: invalid memory address or nil pointer dereference
goroutine 20 [running]:
net/http.(*conn).serve.func1(0xc0000b4f00)
    /usr/local/Cellar/go/1.11.1/libexec/src/net/http/server.go:1746 +0xd0
panic(0x1445980, 0x182f2b0)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/panic.go:513 +0x1b9
html/template.(*Template).escape(0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.11.1/libexec/src/html/template/template.go:95 +0x2e
html/template.(*Template).Execute(0x0, 0x1532980, 0xc000dcd030, 0x1455120, 0xc000b48a00, 0xc0000bdc60, 0x1)
    /usr/local/Cellar/go/1.11.1/libexec/src/html/template/template.go:119 +0x2f
main.insertTokenToTemplateImpl(0xc000ec6480, 0xb6, 0x1532de0, 0x0, 0x1533400, 0xc000713fb0, 0x0, 0x9)
    /Users/jedrzejszczepaniak/go/src/github.com/jedruniu/spotify-cli/auth.go:191 +0xbc
main.(*appState).authCallback(0xc0000874a0, 0x1536c00, 0xc00016a0e0, 0xc0000c4200)
    /Users/jedrzejszczepaniak/go/src/github.com/jedruniu/spotify-cli/auth.go:99 +0x2d2
main.(*appState).authCallback-fm(0x1536c00, 0xc00016a0e0, 0xc0000c4200)
    /Users/jedrzejszczepaniak/go/src/github.com/jedruniu/spotify-cli/auth.go:72 +0x48
net/http.HandlerFunc.ServeHTTP(0xc0000830a0, 0x1536c00, 0xc00016a0e0, 0xc0000c4200)
    /usr/local/Cellar/go/1.11.1/libexec/src/net/http/server.go:1964 +0x44
net/http.(*ServeMux).ServeHTTP(0xc0000874d0, 0x1536c00, 0xc00016a0e0, 0xc0000c4200)
    /usr/local/Cellar/go/1.11.1/libexec/src/net/http/server.go:2361 +0x127
net/http.serverHandler.ServeHTTP(0xc00016c000, 0x1536c00, 0xc00016a0e0, 0xc0000c4200)
    /usr/local/Cellar/go/1.11.1/libexec/src/net/http/server.go:2741 +0xab
net/http.(*conn).serve(0xc0000b4f00, 0x1537040, 0xc00008e380)
    /usr/local/Cellar/go/1.11.1/libexec/src/net/http/server.go:1847 +0x646
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.11.1/libexec/src/net/http/server.go:2851 +0x2f5
auth.go:90: Could not get token, error: oauth2: cannot fetch token: 400 Bad Request
Response: {"error":"invalid_grant","error_description":"Invalid authorization code"}

EDIT: Manually rebuilding from source following the instructions in the README allows spotify to work properly. I'm wondering if something is just going wrong when you're building the go-binary for release? I don't know enough about how go builds things, or why it's hardcoding them in.

jbszczepaniak commented 4 years ago

I fixed problems reported by users and released new versions Please consider using this one, also remember about requirements for running the project. I am closing this issue, if running newest release will be still problematic for you - feel free to reopen the issue.