- A spotify account
- Create an app in the Spotify account to obtain data crucial to running the app.
- Authourization begins in Auth2Flow.go file in the LoginHandler func
func LoginHandler(){ //code }
- After authourization, making api requests is now possible, this is done in the Getdata.go file inside the GetNowPlaying function.
func GetNowPlaying(){
//code
}
- A struct called SongInfo is created to filter the json to just the parameters desired. Alternatively you can remove this step and sift through all the JSON data recieved.
type SongInfo struct {
SongName string `json:"song_name"`
ArtistName string `json:"artist_name"`
AlbumArt string `json:"album_art"`
IsPlaying bool `json:"is_playing"`
}
- Finally the server can be launched with previously mentioned functions as endpoints in the Auth2Flow.go file inside the Auth function.
func Auth(){
//code
}
-
Run the program by running
go run main.go Auth2Flow.go Getdata.go
in the terminal -
Remember to run sequentially starting with the
:8888/login
endpoint then the:8888/getdata
endpoint in the browser.