Coder Social home page Coder Social logo

geofairy / spoify-playing-serverless Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 24 KB

Azure Server-less function delivering a REST API for obtaining the currently playing or most recently played song on Spotify of a given user

JavaScript 100.00%

spoify-playing-serverless's Introduction

Spoify-Playing-Serverless

Serverless azure function to supply now playing from a given spotify user in JSON format.

Setup

Spotify

  • Create a Spotify Application
  • Take note of:
    • Client ID
    • Client Secret
  • Click on Edit Settings
  • In Redirect URIs:
    • Add http://localhost/callback/

Refresh Token

  • Navigate to the following URL:
https://accounts.spotify.com/authorize?client_id={SPOTIFY_CLIENT_ID}&response_type=code&scope=user-read-currently-playing,user-read-recently-played&redirect_uri=http://localhost/callback/
  • After logging in, save the {CODE} portion of: http://localhost/callback/?code={CODE}

  • Create a string combining {SPOTIFY_CLIENT_ID}:{SPOTIFY_CLIENT_SECRET} (e.g. 5n7o4v5a3t7o5r2e3m1:5a8n7d3r4e2w5n8o2v3a7c5) and encode into Base64.

  • Then run a curl command in the form of:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic {BASE64}" -d "grant_type=authorization_code&redirect_uri=http://localhost/callback/&code={CODE}" https://accounts.spotify.com/api/token
  • Save the Refresh token

.env config

Create the file local.settings.json in the format of:

{
  "IsEncrypted": false,
  "Values": {
    "spotify_client_id": "<<application client id>>",
    "spotify_client_secret": "<<application client secret>>",
    "spotify_refresh_token": "<<user generated refresh token>>",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}

Refer to https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node on how to build and deploy this project locallly or on azure.

spoify-playing-serverless's People

Contributors

geofairy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.