This project, developed by Ing Samuel Seda, is a code challenge from Brillio. It focuses on consuming the Spotify API, implementing OAuth 2.0 login, and performing searches of Tracks Music by ISRC and artist, storing the results in a local MySQL database or interacting with the Spotify API.
go mod tidyswag init --parseDependency trueEnsure you have MySQL installed. If not, you can download it from MySQL Downloads.
In the db/database.go file, set your MySQL user and password in the dsn variable:
dsn := "your_username:your_password@tcp(localhost:3306)/spotify?parseTime=true"Visit Spotify Developer Dashboard and create a new application to obtain your Spotify client ID and client secret.
In the config/oauth.go file, set your Client ID and Client Secret in the clientID & clientSecret variable:
var (
clientID = "your_clientID"
clientSecret = "your_clientSecret"
...
)go run .The application exposes the following endpoints:
- GET /: Welcome page
- GET /login: Initiates the Spotify login flow
- GET /callback: Handles the Spotify callback after a successful login
- GET /search/:isrc: Searches for a track by ISRC code
- GET /search/artist/:name: Searches for tracks by artist name
- *GET /swagger/any: Swagger documentation
The server is listening on port 8080.
-
Obtain a Spotify token by clicking "Login with Spotify" at http://localhost:8080.

-
Use the provided Thunder collection (
/thunder-client-collection) to interact with the defined endpoints.
-
Check the Swagger documentation at http://localhost:8080/swagger/index.html#/.

-
Install Workbench to login to MySql Database Viewer
Note: The token is stored in memory and resets with each server restart, requiring a new login.
:)

