Interface OAuthTokenResponse

OAuth token response interface

Response structure returned when exchanging authorization codes for tokens or refreshing access tokens. This interface defines the complete token response including all metadata needed for authentication and token management.

const tokenResponse: OAuthTokenResponse = {
access_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
refresh_token: 'refresh-token-here',
token_type: 'Bearer',
expires_in: 3600,
sub: 'user-123',
iat: '1640995200',
exp: '1640998800'
};
// Handle token response
const handleTokenResponse = (response: OAuthTokenResponse) => {
// Store tokens securely
localStorage.setItem('access_token', response.access_token);
if (response.refresh_token) {
localStorage.setItem('refresh_token', response.refresh_token);
}

// Calculate expiration time
const expiresAt = new Date(parseInt(response.exp) * 1000);
console.log('Token expires at:', expiresAt);
};
interface OAuthTokenResponse {
    access_token: string;
    refresh_token?: string;
    token_type: string;
    expires_in: number;
    sub: string;
    iat: string;
    exp: string;
}

Properties

access_token: string

JWT access token for API authentication

refresh_token?: string

Refresh token for obtaining new access tokens

token_type: string

Token type (typically 'Bearer')

expires_in: number

Token expiration time in seconds

sub: string

Subject identifier (user ID)

iat: string

Token issued at timestamp

exp: string

Token expiration timestamp