How to use the @esri/arcgis-rest-request.ArcGISAuthError function in @esri/arcgis-rest-request

To help you get started, we’ve selected a few @esri/arcgis-rest-request 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 Esri / arcgis-rest-js / packages / arcgis-rest-auth / src / UserSession.ts View on Github external
public refreshSession(
    requestOptions?: ITokenRequestOptions
  ): Promise {
    // make sure subsequent calls to getUser() don't returned cached metadata
    this._user = null;
    if (this.username && this.password) {
      return this.refreshWithUsernameAndPassword(requestOptions);
    }

    if (this.clientId && this.refreshToken) {
      return this.refreshWithRefreshToken();
    }

    return Promise.reject(new ArcGISAuthError("Unable to refresh token."));
  }
github Esri / arcgis-rest-js / packages / arcgis-rest-auth / src / UserSession.ts View on Github external
.then(response => {
        if (response.owningSystemUrl) {
          /**
           * if this server is not owned by this portal
           * bail out with an error since we know we wont
           * be able to generate a token
           */
          if (!new RegExp(response.owningSystemUrl, "i").test(this.portal)) {
            throw new ArcGISAuthError(
              `${url} is not federated with ${this.portal}.`,
              "NOT_FEDERATED"
            );
          } else {
            /**
             * if the server is federated, use the relevant token endpoint.
             */
            return request(
              `${response.owningSystemUrl}/sharing/rest/info`,
              requestOptions
            );
          }
        } else if (
          response.authInfo &&
          this.trustedServers[root] !== undefined
        ) {
github Esri / arcgis-rest-js / packages / arcgis-rest-auth / src / UserSession.ts View on Github external
);
        win.close();
        return undefined;
      }

      if (win !== win.parent) {
        win.parent[`__ESRI_REST_AUTH_HANDLER_${clientId}`](
          error ? JSON.stringify(error) : undefined,
          JSON.stringify(oauthInfo)
        );
        win.close();
        return undefined;
      }

      if (error) {
        throw new ArcGISAuthError(error.errorMessage, error.error);
      }

      return new UserSession({
        clientId,
        portal,
        ssl: oauthInfo.ssl,
        token: oauthInfo.token,
        tokenExpires: oauthInfo.expires,
        username: oauthInfo.username
      });
    }
github Esri / arcgis-rest-js / packages / arcgis-rest-auth / src / UserSession.ts View on Github external
win[`__ESRI_REST_AUTH_HANDLER_${clientId}`] = function(
      errorString: any,
      oauthInfoString: string
    ) {
      if (errorString) {
        const error = JSON.parse(errorString);
        session.reject(new ArcGISAuthError(error.errorMessage, error.error));
        return;
      }

      if (oauthInfoString) {
        const oauthInfo = JSON.parse(oauthInfoString);
        session.resolve(
          new UserSession({
            clientId,
            portal,
            ssl: oauthInfo.ssl,
            token: oauthInfo.token,
            tokenExpires: new Date(oauthInfo.expires),
            username: oauthInfo.username
          })
        );
      }
github Esri / solution.js / packages / common / src / resourceHelpers.ts View on Github external
return new Promise((resolve, reject) => {
      reject(
        new request.ArcGISAuthError(
          "Filename must have an extension indicating its type"
        )
      );
    });
  }