import Base from '../api/base'; import { Scope } from '../types'; export declare type Token = { access_token: string; expires_in: number; token_type: string; }; export declare type ClientToken = Token; export declare type AuthToken = Token & { refresh_token: string; refresh_token_expires_in: number; }; /** * https://developer.ebay.com/api-docs/static/oauth-tokens.html * * Client credentials grant flow mints a new Application access token that you can use to access the resources owned by the application. * Authorization code grant flow mints a new User access token that you can use to access the resources owned by the user. */ export default class OAuth2 extends Base { static readonly IDENTITY_ENDPOINT: Record; static readonly AUTHORIZE_ENDPOINT: Record; static readonly defaultScopes: Scope; static generateAuthUrl(sandbox: boolean, appId: string, ruName: string, scope: string[], state?: string): string; private scope; private _clientToken?; private _authToken?; get identityEndpoint(): string; /** * Return the access token. * First return user access token, if not set Application Access Token. */ getAccessToken(): Promise; getUserAccessToken(): string | null; getApplicationAccessToken(): Promise; setClientToken(clientToken?: Token): void; setScope(scope: Scope): void; getScope(): string[]; /** * Client credentials grant flow. */ mintApplicationAccessToken(): Promise; /** * Client credentials grant flow. */ obtainApplicationAccessToken(): Promise; /** * Generates URL for consent page landing. * * @param ruName RuName * @param scope the scopes * @param state state parameter returned in the redirect URL */ generateAuthUrl(ruName?: string, scope?: string[], state?: string): string; /** * Authorization code grant flow. * * Mint the user access token for the given code. * * @param code the code * @param ruName the redirectUri */ mintUserAccessToken(code: string, ruName?: string | undefined): Promise; /** * Authorization code grant flow. * * Mint the access token for the given code. * * @param code the code * @param ruName the redirectUri */ getToken(code: string, ruName?: string | undefined): Promise; /** * Authorization code grant flow. */ refreshUserAccessToken(): Promise; /** * Gets and sets the user access token for the given code. * * Authorization code grant flow. * * @param code the code */ obtainToken(code: string): Promise; getCredentials(): AuthToken | ClientToken | null; setCredentials(authToken: AuthToken | string): void; /** * Refresh the user access token if set or application access token */ refreshToken(): Promise; }