mohanvaddi / spotify-OAuth2.0-ts

Spotify OAuth2.0 'authorization_code' workflow with typescript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spotify Web api OAuth2.0 Authentication with TypeScript.

  • This project only covers the Authorization code workflow of OAuth2.0 following the rules mentioned in the Authorization Guide.

Note:

  • If you want this application to redirect the user to a given frontend application with a valid access_token as a parameter in the url, then check spotify-OAuth2.0-ts-bridge repo.

Installation:

$ npm install

Steps to acquire credentials from the spotify web api:

  • Register your app and get your own client_id and client_secret from the Spotify Developers Dashboard.
  • To do so, go to your Spotify Developers Dashboard and create your application.
  • Then registered Redirect URIs in the app settings,
  • The redirect uri must be: <Your App url>/callback/
  • Please make note of client_id, client_secret and redirect_uri.
    • After creating your app, create a .env file in the root folder of the project.

Create .env file and add:

 SPOTIFY_CLIENT_ID = '<your spotify client id>'
 SPOTIFY_CLIENT_SECRET = '<your spotify client secret>'
 SPOTIFY_CLIENT_REFRESH_TOKEN = '<Refresh Token if available upfront>'
 APP_URI = '<url of your app with port included>'
  • Note: Incase of development server, your APP_URI will be http://localhost:3000/. but if you deployed it in heroku or any other platform, chane the APP_URI accordingly.

To run:

  • Start script is already included in the package.json, so run npm start to start the server:

$ npm start

About

Spotify OAuth2.0 'authorization_code' workflow with typescript.


Languages

Language:HTML 53.9%Language:TypeScript 46.1%