1

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

JimRae
  • 111
  • 3
  • I did find this post: http://stackoverflow.com/questions/10503375/desire2learn-valence-api-non-interactive-authentication?rq=1 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 Mar 20 '14 at 19:19

1 Answers1

0

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.

Community
  • 1
  • 1
Paul Gray
  • 546
  • 1
  • 5
  • 10
  • I tried to do it this way as well, and still get an error. I used the API test tool (that you mentioned), and authenticated with my credentials, then took the generated UID and Ukey and applied them to my code, but no joy. The sample app does work by the way, so I do know my credentials are able to Create an User. Thanks for responding. Can you share how you developed your code? Did you use one of the SDKs, or develop everything yourself? What language were you developing in? – JimRae Mar 21 '14 at 15:20
  • I am developing in Java, using the Java valence sdk located [here](https://github.com/Desire2Learn-Valence/valence-sdk-java). I made a large number of changes to make it easier conceptually to make requests to the server. I also deprecated some methods that I thought were unnecessary. I would advise updating to the current version of the github repo, and using the non-deprecated methods provided. If you still need help, maybe you can email me with some of your code and we can figure it out together. – Paul Gray Mar 21 '14 at 15:28
  • Thanks, I am also using the Java SDK, downloaded about 30 days ago. I will check to make sure there is not changes that I need to incorporate. I am actually using a system that leverages a proprietary code base similar to Java, so I did have to make some changes in order to get my code to compile, and had to replace some elements that did not exist in my system with an equivalent. I do appreciate the offer of assistance, and will reach out if the update doesn't help. As a side note, I do have a case open with the D2L team as well. – JimRae Mar 21 '14 at 15:46
  • I'm following up to this question over in the Valence user forums in the thread entitled "non-interactive webservice workflow" (https://groups.google.com/forum/#!topic/valenceusers/3gh1q8nGZPQ), as it seems to me that there might be more needed for discussion than just Question:Answer. – Viktor Haag Mar 24 '14 at 13:39