Setting up Spotify Authentication on ASP.NET CORE 2.2

  • A Spotify developer account — Register
  • A working asp.net web app with individual authentication already configured
  • AspNet.Security.OAuth.Spotify NuGet package
  • Once you’ve satisfied ALL the above requirements , follow the steps shown below

Step 1 : Create a new Spotify app

  • Navigate to the Spotify developer console and create a new App
  • Copy the client secret and client id to your appsettings.json file
  • Click on the Edit settings button and add a redirect URI — This is the route that will be called once the user is authenticated by Spotify.
  • If you are running your app locally, this will typically be https://localhost:44377/callback

Step 2: Add Spotify authentication middleware inside ‘startup.cs’

  • Next add the Spotify middleware options inside the ConfigureServices method in your startup.cs file

Step 3: Test

  • If you are lucky:), your app should now have an option to login with Spotify as shown below:
Image for post
Image for post
  • When you successfully authenticate with Spotify, you should see this screen:
Image for post
Image for post
  • This will create a new user with no password on your users database
  • In addition, the user’s Id will be associated with the Spotify provider inside the AspNet.UserLogins database.
  • Learn more about external authentication providers here.

Written by

Former Glorified Electrician(aka Electrical Engineer). Now a Software Developer working on complex Enterprise Software. Lets connect on twitter @NdamuleloNemakh

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store