sgotify

module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: MIT

README

Sgotify

GoDoc

Sgotify is a wrapper around the Spotify API written in Go. It supports all the endpoints listed in Web API.

Install

go install github.com/Alieksieiev0/sgotify@latest

Usage

Sgotify uses the Authorization Code Flow to authorize user and send requests, because it provides with the widest access to the API. It requires user to create an app to get from it client id and secret. Sgotify will search for them in environment variables, using the following names:

  • Client Id - SPOTIFY_CLIENT_ID
  • Client Secret - SPOTIFY_CLIENT_SECRET

Currently, Sgotify provides pre-built logic for authorization from terminal applications. To authorize from Terminal, the only code needed is

	ctx := context.Background()
	term := services.NewTerminal(redirectUri)
	token, err := term.Authorize(ctx)

redirectUri must have been added to the redirect URI allow list that you specified when registering your application. Example: http://localhost:8888/callback. The next step would be to create a Spotify client using the token you received. This can be done with a single command

	spotify := api.NewSpotifyClient(ctx, token)

From now on, you can use this client to make requests to the Spotify API.

Directories

Path Synopsis
examples
cli
pkg
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL