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

    Authentication namespace — OAuth token grants and session management.

    const token = await sc.auth.getClientToken();
    sc.setToken(token.access_token);
    Index

    Constructors

    Methods

    • Build the authorization URL to redirect users to SoundCloud's OAuth login page.

      Parameters

      • Optionaloptions: { codeChallenge?: string; state?: string }

        Optional parameters for the authorization request

        • OptionalcodeChallenge?: string

          PKCE S256 code challenge for enhanced security

        • Optionalstate?: string

          Opaque state value for CSRF protection

      Returns string

      The full authorization URL to redirect the user to

      If redirectUri was not provided in the client config

      const url = sc.auth.getAuthorizationUrl({ state: 'random-state' });
      // Redirect user to `url`
    • Invalidate the session associated with an access token.

      Note: This hits https://secure.soundcloud.com, NOT the regular api.soundcloud.com host used by all other endpoints.

      Parameters

      • accessToken: string

        The access token to invalidate

      Returns Promise<void>

      When the sign-out request fails

      await sc.auth.signOut(sc.accessToken!);
      sc.clearToken();