soundcloud-api-ts - v1.9.0
    Preparing search index...

    Function getUserToken

    • Exchange an authorization code for user tokens (authorization_code grant).

      This is a standalone function alternative to SoundCloudClient.Auth.getUserToken.

      Parameters

      • clientId: string

        Your SoundCloud application's OAuth client ID

      • clientSecret: string

        Your SoundCloud application's OAuth client secret

      • redirectUri: string

        The redirect URI registered with your SoundCloud application

      • code: string

        The authorization code received from the OAuth callback

      • OptionalcodeVerifier: string

        PKCE code verifier if a code challenge was used during authorization

      Returns Promise<SoundCloudToken>

      The OAuth token response including access and refresh tokens

      When the code is invalid, expired, or credentials are wrong

      import { getUserToken } from 'soundcloud-api-ts';

      const token = await getUserToken(
      'YOUR_CLIENT_ID',
      'YOUR_CLIENT_SECRET',
      'https://example.com/callback',
      authorizationCode,
      codeVerifier, // optional, for PKCE
      );
      console.log(token.access_token, token.refresh_token);