AniLink - v3.1.0
    Preparing search index...

    Function buildMalAuthorizationUrl

    • buildMalAuthorizationUrl is the PKCE helper that builds the MyAnimeList OAuth2 authorization URL for getMalAccessToken.

      It encodes the client identity and PKCE challenge from MalAuthorizationCodeRequest and returns the URL to open in a browser. MAL's authorization server currently supports only the plain PKCE method. Validate the state on redirect before exchanging the code via getMalAccessToken.

      Parameters

      • clientId: string

        The MAL application client ID from MalAuthorizationCodeRequest.clientId.

      • codeChallenge: string

        The PKCE challenge for the login attempt; under MAL's plain method this is the verifier itself and must contain 43 to 128 RFC 7636 unreserved characters.

      • Optionalstate: string

        Optional opaque CSRF state to validate on the redirect.

      Returns string

      The encoded authorization URL for the MAL OAuth flow.

      TypeError when codeChallenge is not a valid MAL PKCE verifier.

      const codeVerifier = "a".repeat(43);
      const url = buildMalAuthorizationUrl("client-id", codeVerifier, "csrf-state");
      // Open url in a browser, then exchange the returned code with getMalAccessToken.