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

@itwin/browser-authorization does not return any error codes #92

Closed
Tracked by #102
tangytang opened this issue Dec 16, 2022 · 2 comments
Closed
Tracked by #102

@itwin/browser-authorization does not return any error codes #92

tangytang opened this issue Dec 16, 2022 · 2 comments
Assignees
Labels
browser Related to the browser authorization need reproduction

Comments

@tangytang
Copy link

tangytang commented Dec 16, 2022

/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
import {
  BrowserAuthorizationClient,
  BrowserAuthorizationClientConfiguration,
} from '@itwin/browser-authorization';

import { appConfig } from './AppConfigService';

class AuthorizationService {
  private _authorizationClient: BrowserAuthorizationClient | undefined;

  private async createAuthorizationClient(): Promise<
    BrowserAuthorizationClient
  > {
    const authorizationClientConfiguration: BrowserAuthorizationClientConfiguration = {
      authority: appConfig.auth.authority,
      clientId: appConfig.auth.clientId,
      redirectUri: appConfig.auth.redirectUrl,
      postSignoutRedirectUri: undefined,
      scope: appConfig.auth.scopes,
      responseType: 'code',
    };

    const client = new BrowserAuthorizationClient(
      authorizationClientConfiguration,
    );

    return client;
  }

  public async getAccessToken(): Promise<string> {
    if (!this._authorizationClient) {
      this._authorizationClient = await this.createAuthorizationClient();

      try {
        await this._authorizationClient.signIn();
      } catch (err) {
        throw {
          message: err,
        };
      }
    }

    return this._authorizationClient.getAccessToken();
  }
}

export const authorizationService = new AuthorizationService();

Hi All,

I'm trying to find out why the authorization client does not return anything when the signIn method is called, but i get the following response that is difficult to understand:

{"message":"failed to retrieve issues","error":{"message":{}}}

As you can see, it does not seem to return any error message. Any ideas how I can find out the cause of the error and how to resolve it?

@ben-polinsky
Copy link
Collaborator

I would check the browser dev console and network logs. In most case, we do not swallow errors. When we do, the error message is direct as to the cause on our end, though I do see a couple areas we could improve.

Perhaps the unclear error is from your identity provider.

@ben-polinsky ben-polinsky added question Further information is requested need reproduction and removed needs triage question Further information is requested labels Mar 7, 2023
@ben-polinsky
Copy link
Collaborator

@tangytang if you're still seeing this issue, a reproducible example would help.

@ben-polinsky ben-polinsky closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser Related to the browser authorization need reproduction
Projects
None yet
Development

No branches or pull requests

4 participants