Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPA Documentation is not latest. authClient.handleLoginRedirect not available. #3497

Open
dpgbt opened this issue Jan 3, 2024 · 1 comment
Labels

Comments

@dpgbt
Copy link

dpgbt commented Jan 3, 2024

Describe the bug

Custom hosted signin widget in OIDC mode for SPA.
signin.authClient.handleLoginRedirect(res.tokens) not avialable.
Any clear documetnation on getting interaction_code on redirectURI and then using /token to fetch tokens?

Reproduction Steps

Custom hosted signin widget in OIDC mode for SPA.
signin.authClient.handleLoginRedirect(res.tokens) not avialable.
Any clear documetnation on getting interaction_code on redirectURI and then using /token to fetch tokens?

SDK Versions

7.13

Additional Information

No response

@dpgbt dpgbt added the bug label Jan 3, 2024
@ryanmr
Copy link

ryanmr commented Feb 17, 2024

I also noticed that the documentation for the showSignIn method is not quite right.

oktaSignIn.showSignIn({
  // Assumes there is an empty element on the page with an id of ‘osw-container’
  el: #osw-container’,
}).then(response => {
  oktaSignIn.authClient.handleLoginRedirect(res.tokens);
}).catch(function(error) {
  // This function is invoked with errors the widget cannot recover from:
  // Known errors: CONFIG_ERROR, UNSUPPORTED_BROWSER_ERROR
  console.log('login error', error);
});
  1. The quotes for around the #osw-container are decorative quotes - not single quote literals.

  2. oktaSignIn.authClient.handleLoginRedirect(res.tokens) errors out as

    Property 'handleLoginRedirect' does not exist on type 'WidgetOktaAuthInterface'.ts(2339)

    You can workaround this by using oktaAuth.handleLoginRedirect instead.

  3. oktaSignIn.authClient.handleLoginRedirect(res.tokens) errors out as res does not exist; in the sample code it was named response

  4. oktaAuth.handleLoginRedirect(response) has a typescript error as:

    Argument of type 'RenderResult' is not assignable to parameter of type 'Tokens | undefined'.
    Type 'RenderResultSuccess' is not assignable to type 'Tokens | undefined'.ts(2345)

    You can workaround this by casting the response and the tokens property.

    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    oktaAuth.handleLoginRedirect((response as unknown as any).tokens as Tokens);

    Another option is using a more specific type. I'm not sure why the types in the library do not line up this way though automatically.

    .then((response) => {
      oktaAuth.handleLoginRedirect(
        (response as RenderResultSuccessOIDC).tokens
      );
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants