diff --git a/packages/arcgis-rest-auth/src/UserSession.ts b/packages/arcgis-rest-auth/src/UserSession.ts index 1aaa407811..0ae4ce5866 100644 --- a/packages/arcgis-rest-auth/src/UserSession.ts +++ b/packages/arcgis-rest-auth/src/UserSession.ts @@ -625,7 +625,7 @@ export class UserSession implements IAuthenticationManager { */ getToken(url: string) { if ( - /^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal) && + /^https?:\/\/\S+\.arcgis\.com\/sharing\/rest/.test(this.portal) && /^https?:\/\/\S+\.arcgis\.com.+/.test(url) ) { return this.getFreshToken(); diff --git a/packages/arcgis-rest-auth/test/UserSession.test.ts b/packages/arcgis-rest-auth/test/UserSession.test.ts index af8a1ad281..6eb1d48067 100644 --- a/packages/arcgis-rest-auth/test/UserSession.test.ts +++ b/packages/arcgis-rest-auth/test/UserSession.test.ts @@ -65,6 +65,27 @@ describe("UserSession", () => { }); }); + it("should return unexpired tokens when an org url is passed", done => { + const session = new UserSession({ + clientId: "id", + token: "token", + tokenExpires: TOMORROW, + portal: "https://custom.maps.arcgis.com/sharing/rest" + }); + + session + .getToken( + "https://services1.arcgis.com/MOCK_ORG/arcgis/rest/services/Private_Service/FeatureServer" + ) + .then(token => { + expect(token).toBe("token"); + done(); + }) + .catch(e => { + fail(e); + }); + }); + it("should return unexpired tokens for the configured portal domain", done => { const session = new UserSession({ clientId: "id",