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

add UserSession.getCredential() #219

Merged
merged 1 commit into from
Jun 13, 2018
Merged

add UserSession.getCredential() #219

merged 1 commit into from
Jun 13, 2018

Conversation

jgravois
Copy link
Contributor

@jgravois jgravois commented Jun 13, 2018

first pass at #208

PRing against the amd branch for the sake of the demo.

require([
  "@esri/arcgis-rest-auth",
  "@esri/arcgis-rest-items",
  "esri/identity/IdentityManager",
  "esri/WebMap"
], function(
  arcgisAuth, arcgisItems, esriId, WebMap
) {
  const session = new arcgisAuth.UserSession({
    username: "arcgis_python",
    password: "P@ssword123"
  });

  // https://geosaurus.maps.arcgis.com/home/item.html?id=728043ac6a574a00b8f1cd5ee0eae8cd
  arcgisItems.getItemData("728043ac6a574a00b8f1cd5ee0eae8cd", { authentication: session })
    .then(response => {
      esriId.registerToken(session.getCredential());

      new WebMap({
        portalItem: {
          // dig the webmap id out of the response
          id: response.map.itemId
        }
      });
    });
});

@jgravois jgravois requested a review from tomwayson June 13, 2018 18:13
@coveralls
Copy link

coveralls commented Jun 13, 2018

Coverage Status

Coverage increased (+0.001%) to 99.326% when pulling c03430d on feat/jsapi-auth into 0cc7aaa on master.

@@ -510,6 +520,19 @@ export class UserSession implements IAuthenticationManager {
});
}

// do we need to allow for passing a url?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet, so far we don't store multiple credentials.

@@ -510,6 +520,19 @@ export class UserSession implements IAuthenticationManager {
});
}

// do we need to allow for passing a url?
// trap for when session isnt fully hydrated?
// should this return a promise?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so - let the consuming app decide if the half baked credential is valid for their use case or not

@jgravois
Copy link
Contributor Author

jgravois commented Jun 13, 2018

tacked on another commit to use dojoConfig to identify the location of our UMDs instead of <script> tags and revert the rollup change.

then rebased.

@jgravois jgravois changed the base branch from amd to master June 13, 2018 22:02
AFFECTS PACKAGES:
@esri/arcgis-rest-auth

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

Successfully merging this pull request may close these issues.

3 participants