Skip to content

Instantly share code, notes, and snippets.

View Uvacoder's full-sized avatar

uvacoder Uvacoder

View GitHub Profile
@Uvacoder
Uvacoder / .env
Created June 16, 2024 22:21 — forked from bitttttten/.env
Fetch Spotify Recently Played from Netlify function
SPOTIFY_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxx
SPOTIFY_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxx
SPOTIFY_REFRESH_TOKEN=aaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-cccccccccccccccc-dddddddddddddddd-eeeeeeeeeeeeeeee
@Uvacoder
Uvacoder / spotify-listening.md
Created June 16, 2024 22:18 — forked from nathanielfernandes/spotify-listening.md
Using a cloudflare worker to get your listening activity from spotify

Using a cloudflare worker to get your listening activity from spotify

In this guide I will explain how to create a cloudflare worker that returns the current song you are listening to on spotify.

You may of seen my use of it on root of my site:
listening

Step 1: Get your Spotify client_id, client_secret and refresh_token

@Uvacoder
Uvacoder / last-played-spotify-song.js
Created June 16, 2024 22:16 — forked from mkriegeskorte/last-played-spotify-song.js
Get recently played Spotify Track in serverless function running on vercel
const axios = require('axios')
const spotifyAPIBaseUri = 'https://api.spotify.com'
const spotifyAccountsBaseUri = 'https://accounts.spotify.com'
const {
SPOTIFY_CLIENT_ID, // Your Spotify OAuth Client ID
SPOTIFY_CLIENT_SECRET, // Spotify OAuth Client Secret
SPOTIFY_REFRESH_TOKEN, // Your personal refresh token (you have to authenticate yourself against your app once to receive this)
} = process.env
@Uvacoder
Uvacoder / spotify.md
Created June 16, 2024 22:10 — forked from skidoodle/spotify.md
How to get your Spotify tokens
  1. Create an application in the Spotify Developer Dashboard
    • Click on the Edit settings button
    • Set the Redirect URIs to a convenient location (doesn't matter)
    • Save the given Client ID along with the Client Secret
  2. Retrieve the access code
    • Visit the following URL after replacing $CLIENT_ID, $SCOPE, and $REDIRECT_URI
    https://accounts.spotify.com/authorize?response_type=code&client_id=$CLIENT_ID&scope=$SCOPE&redirect_uri=$REDIRECT_URI
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
function makeErrorResponse(message) {
return new Response(message, {
status: 404,
statusText: 'not found',
headers: {
'content-type': 'text/plain',
@Uvacoder
Uvacoder / [...nextauth].ts
Created June 16, 2024 22:08 — forked from Eppu/[...nextauth].ts
Spotify refresh token rotation using NextAuth's Spotify provider
import NextAuth from 'next-auth/next';
import SpotifyProvider from 'next-auth/providers/spotify';
import type { Session } from 'next-auth';
import { JWT } from 'next-auth/jwt';
import axios from 'axios';
const SPOTIFY_REFRESH_TOKEN_URL = 'https://accounts.spotify.com/api/token';
const SPOTIFY_CLIENT_ID = process.env.SPOTIFY_CLIENT_ID!;
const SPOTIFY_CLIENT_SECRET = process.env.SPOTIFY_CLIENT_SECRET!;
@Uvacoder
Uvacoder / spotify-api.md
Created June 16, 2024 22:04 — forked from jeffersonrj14/spotify-api.md
Spotify API : Authorization Code and Refresh Token

First: Create a Spotify Developer Account:

If you haven't already, sign up for a Spotify Developer account at the Spotify Developer Dashboard.

Second: Create a Spotify Application:

After logging into the Spotify Developer Dashboard, create a new application to obtain your client ID and client secret.

Third: Edit Settings

https://localhost:3000, Add it as a Redirect URI.

Fourth: Authorization Request

@Uvacoder
Uvacoder / spotify-token-app.js
Created June 16, 2024 22:02 — forked from Symbitic/spotify-token-app.js
Example of obtaining a Spotify token
/*
Make sure to download spotify-token-index.html and rename it to public/index.html
Before running this application, make sure to replace CLIENT_ID and CLIENT_SECRET below.
Also, make sure to register http://localhost:8989/ and http://localhost:8989/callback/ as callbacks in your developer console.
THE TRAILING SLASHES ARE IMPORTANT!
Run this with:
deno run -A spotify-token-app.js
*/
@Uvacoder
Uvacoder / index.html
Created June 16, 2024 22:01 — forked from outloudvi/index.html
Getting a Spotify refresh_token
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OAuth | Spotify</title>
</head>
//https://www.thathandsomebeardedguy.com/i'd-love-to-❤️-you-more
var credentials = {
clientId: 'someclientid',
clientSecret: 'someclientsecret',
redirectUri: 'http://localhost:8888/callback'
};
//npm install spotify-web-api-node --save
var SpotifyWebApi = require('spotify-web-api-node');
var spotifyApi = new SpotifyWebApi(credentials);
//npm install fs