lunify.js
Version:
A basic api wrapper for the spotify api covering the oauth routes.
33 lines (32 loc) • 1.2 kB
TypeScript
/// <reference types="node" />
import { EventEmitter } from 'stream';
import { Lunify, Scopes } from '../..';
import { UserOauth } from '../../structures/user';
export declare class OauthManager extends EventEmitter {
client: Lunify;
constructor(client: Lunify);
/**
* Create a oAuth url for users to authorize
* @param {Scopes[]} scopes - A list of spotify scopes {@link https://developer.spotify.com/documentation/web-api/concepts/scopes}
* @param {?string} state - If you want to use your own state use this
*/
generateUrl(scopes: Scopes[], state?: string): string;
/**
* Get a spotify access token from a oAuth code
* @param {string} code - oauth response query code
* @example ```ts
* const code = req.query.code;
* const access = await api.oauth.fetchToken(code);
* ```
*/
fetchToken(code: string): Promise<UserOauth>;
/**
* Refresh a spotify access token
* @param {string} refreshToken - oauth refresh token
* @example ```ts
* const refreshToken = ...;
* await api.oauth.refreshToken(refreshToken);
* ```
*/
refreshToken(refreshToken: string): Promise<UserOauth>;
}