Skip to content

Instantly share code, notes, and snippets.

View Eppu's full-sized avatar
😵‍💫

Eetu Eskelinen Eppu

😵‍💫
View GitHub Profile
@Eppu
Eppu / [...nextauth].ts
Last active June 16, 2024 22:08
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!;

Implementation

  • Does this change accomplish what it's supposed to do?
  • Could this solution be simplified?
  • Could the maintainability or readability be improved?
  • Does similar functionality already exist in the code? If so, why is it not used?
  • Does the solution use hard-coded variables? If so, could they be changed?
  • Are there any best practices that could substantially improve this code?

Logic errors

  • Can you think of any use case in which the code doesn't behave as intended?