Open
Description
Proposal
JavaScript unbranded libraries will provide a flexible interface to support various authentication providers, as shown in the example below. We believe that flexibility + good samples is the right strategy for unbranded JS customers.
For the MVP, our proposal is to expose TokenCredential
from the generated client and internally add a Bearer Token pipeline policy. We don’t believe a separate library is needed solely for unbranded identity.
Example: Using Auth0 with Our Libraries (TypeScript)
import { Auth0Client } from "@auth0/auth0-spa-js";
import { TokenCredential, MyClient } from "my-unbranded-lib";
const auth0Client = new Auth0Client({
domain: "your-auth0-domain",
clientId: "your-client-id",
authorizationParams: {
audience: "your-api-identifier",
},
});
const auth0Credential: TokenCredential = {
async getToken(scopes: string | string[], options?: GetTokenOptions) {
try {
const token = await auth0Client.getTokenSilently({
authorizationParams: {
scope: Array.isArray(scopes) ? scopes.join(" ") : scopes,
},
});
return token ? { token, expiresOnTimestamp: Date.now() + 3600 * 1000 } : null;
} catch (error) {
console.error("Failed to retrieve token from Auth0", error);
return null;
}
},
};
const client = new MyClient(auth0Credential);
Looking forward to feedback! 🚀