How to use the @openid/appauth/built/token_request.TokenRequest function in @openid/appauth

To help you get started, we’ve selected a few @openid/appauth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlesamples / appauth-js-electron-sample / flow.ts View on Github external
performWithFreshTokens(): Promise {
    if (!this.configuration) {
      log("Unknown service configuration");
      return Promise.reject("Unknown service configuration");
    }
    if (!this.refreshToken) {
      log("Missing refreshToken.");
      return Promise.resolve("Missing refreshToken.");
    }
    if (this.accessTokenResponse && this.accessTokenResponse.isValid()) {
      // do nothing
      return Promise.resolve(this.accessTokenResponse.accessToken);
    }
    let request = new TokenRequest(
      clientId,
      redirectUri,
      GRANT_TYPE_REFRESH_TOKEN,
      undefined,
      this.refreshToken
    );
    return this.tokenHandler
      .performTokenRequest(this.configuration, request)
      .then(response => {
        this.accessTokenResponse = response;
        return response.accessToken;
      });
  }
}
github FlashAirDevelopers / FlashAirFileManager / src / main / auth.js View on Github external
_performWithInitTokenRequest(code) {
    if (!this.authConfiguration) {
      return Promise.resolve();
    }
    const extra = [];
    if (this.codePair) {
      extra['code_verifier'] = this.codePair.codeVrifier;
      log.debug(extra);
    }
    // use the code to make the token request.
    const request = new TokenRequest(
      this.config.clientId, this.config.redirectUri,
      GRANT_TYPE_AUTHORIZATION_CODE, code, undefined, extra);

    return this.tokenHandler.performTokenRequest(this.authConfiguration, request)
    .then(response => {
      this.accessTokenResponse = response;
      return new AuthAccessToken(
        response.accessToken,
        response.refreshToken,
        response.issuedAt + response.expiresIn
      );
    })
    .then(this.tokenStoreHander);
  }
  _performWithFreshTokens(accessToken) {
github googlesamples / appauth-js-electron-sample / flow.ts View on Github external
private makeRefreshTokenRequest(code: string): Promise {
    if (!this.configuration) {
      log("Unknown service configuration");
      return Promise.resolve();
    }
    // use the code to make the token request.
    let request = new TokenRequest(
      clientId,
      redirectUri,
      GRANT_TYPE_AUTHORIZATION_CODE,
      code,
      undefined
    );

    return this.tokenHandler
      .performTokenRequest(this.configuration, request)
      .then(response => {
        log(`Refresh Token is ${response.refreshToken}`);
        this.refreshToken = response.refreshToken;
        this.accessTokenResponse = response;
        return response;
      })
      .then(() => {});
github FlashAirDevelopers / FlashAirFileManager / src / main / auth.js View on Github external
_performWithFreshTokens(accessToken) {
    if (!this.config || !this.authConfiguration) {
      return Promise.reject('Unknown service configuration');
    }
    if (!accessToken || !accessToken.refreshToken) {
      return Promise.resolve('Missing refreshToken.');
    }
    if (accessToken && accessToken.isValid()) {
      log.debug('accessToken is valid');
      // do nothing
      return Promise.resolve(accessToken);
    }
    const request = new TokenRequest(
      this.config.clientId, this.config.redirectUri,
      GRANT_TYPE_REFRESH_TOKEN, undefined, accessToken.refreshToken);
    return this.tokenHandler.performTokenRequest(this.authConfiguration, request)
    .then(response => {
      this.accessTokenResponse = response;
      return new AuthAccessToken(
        response.accessToken,
        response.refreshToken,
        response.issuedAt + response.expiresIn
      );
    })
    .then(this.tokenStoreHander);
  }
  logout() {