Closed MaxCCC closed 2 years ago
What happens if you pass an empty string to NewAuthenticator?
By the way, https://github.com/zmb3/spotify/pull/123 shows how you can pass a pre-initialized http client into this library. You could just initialize yours by creating the client, setting up OAuth2 on it and passing the created http client in.
Pardon me for necro-ing this issue but I believe this might be useful.
This was solved for my Go client, which uses an oauth2 token coming from a file on disk.
All you need is the oauth2.Token
structure with the data. From https://github.com/ambientsound/visp/blob/5d5f7fd9feea2c2bbe82ba1d022fdfd5702c7578/prog/api.go#L29:
token := &oauth2.Token{ ... (fill in token from your Javascript frontend) ... }
httpClient := oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(token))
spotifyClient := spotify.NewClient(httpClient)
This issue has been stalling here for quite some time, but anyways can be helpful I just opened this PR #172 that showcases this use case.
I'm going to go ahead and close as @bretanac93's demo shows this. If this re-occurs, please open a new ticket.
I use javascript (frontend) to do the authorization. Now I want to use Go as backend and use this client to do API calls against the Spotify API.
In this example: https://github.com/zmb3/spotify/blob/master/examples/authenticate/authcode/authenticate.go you do the authentication and stuff in go.
How can I initialize
auth
without doing the newAuthorization in Go?client := auth.NewClient(tok)
Currently I have it working but I still need to define the callback URL in the auth section while I would think it's unnecessary in my case: