workos / authkit

The world's best login box powered by WorkOS and Radix.
https://authkit.com
MIT License
2.15k stars 77 forks source link

Issue building the app locally because of SSO_ENABLED_ORGANIZATION_ID #6

Closed pranitl closed 9 months ago

pranitl commented 9 months ago

Im getting an error when trying to build this app where the getAuthorizationUrl method is being called with a clientId, organizationId, and redirectUri. The organizationId is being fetched from the environment variable SSO_ENABLED_ORGANIZATION_ID. I don't have any need for this because I'm just testing this out locally. As such the environment variable is not set, it could be the cause of the error. Are there any remedies for this?

pmarsceill commented 9 months ago

@rasterize-art the SSO example requires an organizationId be passed into the getAuthorizationUrl method, this way WorkOS would know which identity provider to send the user to (Azure AD, Okta, etc...). If you don't care to try SSO, you can comment out this example for testing purposes. The other examples only require a clientId be passed (plus an API key to instantiate workos).

export default function SignInWithSSO({
  searchParams,
}: {
  searchParams: { [key: string]: string | string[] | undefined };
}) {
  // const ssoUrl = workos.userManagement.getAuthorizationUrl({
  //   clientId: process.env.WORKOS_CLIENT_ID || '',
  //   organizationId: process.env.SSO_ENABLED_ORGANIZATION_ID || '',
  //   redirectUri: 'http://localhost:3000/using-your-own-ui/sign-in/sso/callback',
  // });

  const result = JSON.parse(String(searchParams.response ?? '{ "error": null }'));

  return (
    <main>
      <h1>Sign-in</h1>
      <h2>Single Sign-On</h2>
      {/* <a href={ssoUrl}>Continue with SSO</a> */}
      <pre>{JSON.stringify(result, null, 2)}</pre>
    </main>
  );
}