mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-02-02 12:57:49 +01:00
debug
This commit is contained in:
@@ -5,8 +5,10 @@ import Redis from '@ioc:Adonis/Addons/Redis'
|
|||||||
import { SpotifyArtist, SpotifyTrack } from 'App/Types/ILocalSpotify'
|
import { SpotifyArtist, SpotifyTrack } from 'App/Types/ILocalSpotify'
|
||||||
import { Artist, InternalPlayerResponse, PlayerResponse, SpotifyToken } from 'App/Types/ISpotify'
|
import { Artist, InternalPlayerResponse, PlayerResponse, SpotifyToken } from 'App/Types/ISpotify'
|
||||||
import Song from 'App/Models/Song'
|
import Song from 'App/Models/Song'
|
||||||
|
import Logger from '@ioc:Adonis/Core/Logger'
|
||||||
|
|
||||||
export function getSpotifyAccount(): { access: string; refresh: string } {
|
export function getSpotifyAccount(): { access: string; refresh: string } {
|
||||||
|
Logger.info(JSON.parse(readFileSync('spotify.json').toString()))
|
||||||
return JSON.parse(readFileSync('spotify.json').toString())
|
return JSON.parse(readFileSync('spotify.json').toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ export function getAuthorizationURI(): string {
|
|||||||
redirect_uri: `${Env.get('BASE_URL')}/spotify/callback`,
|
redirect_uri: `${Env.get('BASE_URL')}/spotify/callback`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Logger.info(`https://accounts.spotify.com/authorize?${query}`)
|
||||||
return `https://accounts.spotify.com/authorize?${query}`
|
return `https://accounts.spotify.com/authorize?${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +40,8 @@ export async function setupSpotify(code: string): Promise<void> {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Logger.info(String(authorization_tokens))
|
||||||
|
|
||||||
if (authorization_tokens.status === 200) {
|
if (authorization_tokens.status === 200) {
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
'spotify.json',
|
'spotify.json',
|
||||||
@@ -50,6 +55,7 @@ export async function setupSpotify(code: string): Promise<void> {
|
|||||||
|
|
||||||
export async function regenerateTokens(): Promise<void> {
|
export async function regenerateTokens(): Promise<void> {
|
||||||
const refresh_token = getSpotifyAccount().refresh
|
const refresh_token = getSpotifyAccount().refresh
|
||||||
|
Logger.info(refresh_token)
|
||||||
|
|
||||||
const authorization_tokens: AxiosResponse<SpotifyToken> = await axios.post(
|
const authorization_tokens: AxiosResponse<SpotifyToken> = await axios.post(
|
||||||
'https://accounts.spotify.com/api/token',
|
'https://accounts.spotify.com/api/token',
|
||||||
@@ -65,6 +71,7 @@ export async function regenerateTokens(): Promise<void> {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Logger.info(String(authorization_tokens))
|
||||||
if (authorization_tokens.status === 200) {
|
if (authorization_tokens.status === 200) {
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
'spotify.json',
|
'spotify.json',
|
||||||
|
|||||||
Reference in New Issue
Block a user