1
votes

Has anyone successfully created an non-interactive workflow. Basically, what I am trying to accomplish is this. From my CRM, I am trying to do a Valance API callout to my LMS that will create an LMS user when the user is created in the CRM. This needs to occur without any "human interaction". I am using the Valance Java SDK (https://github.com/Desire2Learn-Valence/valence-sdk-java) as a framework for my code, at at its core, am executing this Flow:

  • D2LAppContext DAC = new D2LAppContext(aid,key);
  • URL targetURL = new URL(protocol+endpt + actiontype);
  • URL authEP = DAC.createWebUrlForAuthentication(endpt , hport, targetURL);
  • httprequest (Get) authEP (which returns a 200 status code - OK)
  • ID2LUserContext DUC = DAC.createUserContext(authEP, endpt, hport, true); ( I have also tried this with passing the userid and userkey generated from the API test application, based on logging in as an interactive user.
  • URL userURL = DUC.createAuthenticatedUri(actiontype, 'GET');
  • httprequest (Get) userURL (which returns a 403 status code - Forbidden)

Does anyone have a suggestion on how to accomplish this? One question I have is which userid and userkey is the API expecting? The one I use to login to the LMS with via the UI? Or something returned from the Authorization call? Thanks! Jim

1
I did find this post: stackoverflow.com/questions/10503375/… that I thought would work. What I notice in this, is when I log in, I get the sessionvalues, and when I authenticate, it appears to work (get a status 200, OK) but what is really happening, is I am getting a session expired (redirect to login ) - JimRae

1 Answers

0
votes

This question is similar to a question that I asked recently:

Consuming the Valence API as an application

This is how we solved this problem over at Learning Objects.

Basically, what you need to do is create a service account (a user that your application will masquerade as) with the correct permissions needed to create a user on your D2L server. Then you must requisition a userId and userKey for that user by using one of the sample applications available on D2L's github repo, or their API test tool (kind of hack-ish, but it's the only way).

Once you have the userId and userKey it is only a matter of using them to create signed requests to your D2L server.