Working with Google Workspace

Randall.S.394
Randall.S.394 Posts: 41 🧭
edited August 20 in Social Groups

Our school uses Google Workspace for email. I am working on a program to automate the linking of D2L user accounts with their corresponding Google Workspace accounts. Currently, I have to daily generate a csv file of all users who have not been linked (using the database created from datahub BDS sets). I then use this file in the admin tool in D2L to bulk load them. This is a bit of a kludge already since I have to have an auxiliary table to keep track of the ones I have already done because I have not been able to actually find any way to determine from either the datasets or API if a user has already been linked. This is a task that needs to be automated.

Tech support has suggested I use this route: POST /d2l/api/gae/(version)/linkuser

The idea is that I will run a program that will be a client to both my database server and to our D2L site. I'll use my existing query that generates the CSV to fetch the rows and then use those rows to POST the GoogleAppsLinkingItem with the route I indicated above. I can then log any errors and manually take care of any anomalous cases. If you know of another way to do this, I am open to suggestions.

I am about to start testing, but I am unsure what value goes into (version). When I queried the versions it didn't list anything with a ProductCode of "gae" and when I tried to query the version directly (GET /d2l/api/gae/versions/) it returns null (not to surprising since it wasn't listed).

I did read up on what it means to be 'unstable', however, it seems there really isn't any other choice. So, the question is, how do you determine the version to use or is that part of 'unstable' — that you just start making numbers up. I understand using an unstable route isn't recommended for production use, but there are only 2 of us and so automating anything possible has been the watchword.

I really am trying to do this using the front door and not resort to screen scraping. In the ideal world, this should be able to be done during account creation from our SIS. However, baby steps.

Tagged:

Answers

  • Tejas.M.9338
    Tejas.M.9338 Posts: 20 🤝🏼 image

    Hi @Randall.S.394 ,

    Thank you for reaching out to the Brightspace community. I'm Tejas, a member of the Product Support team. I have been assigned to this question.

    Regarding your query, I found out below article for the API call. Kindly refer to these articles.

    https://docs.valence.desire2learn.com/res/user.html#post--d2l-api-gae-(version)-linkuser

    https://docs.valence.desire2learn.com/basic/conventions.html#term-D2LVERSION

    D2LVersion: A string value that you should treat as a version specifier to indicate the version of the API you want to use. These version strings get built from a major and minor version number (for example: 1.0). Note that each component in the back-end learning platform you’re connecting to will have its own set of versions it can support.

    You can try using the 1.0 version and let me know if you find any issues/queries.

  • Randall.S.394
    Randall.S.394 Posts: 41 🧭

    Thanks. I will try that.

  • Randall.S.394
    Randall.S.394 Posts: 41 🧭

    I finally got back to the project. That didn't work. I have verified that my POST code works elsewhere. II am showing the latest attempt (using version 1.0 — I have used other values: 1.43 and 1.76. I am trying to avoid walking down the entire list of lp and le version for a possible value of gae. I did find it disheartening that the 'gae' may actually be incorrect since /d2l/api/gae/versions/ returns the same thing as /d2l/api/huffa/versions/ or any other nonsense string I put in in place of gae other than lp or le (I am not sure what the complete list is)

    So this is the api_url I am using: https://<school_domain>/d2l/api/gae/1.0/linkuser
    and this is the payload: {"UserName": "rsharpe", "ExternalUserName": "rsharpe@prairiestate .edu", "Domain": "prairiestate.edu", "ShouldNotify": false}

    I get a 404 error — which is very strange since that isn't listed as one of the 'normal' status codes. This seems to indicated that that path doesn't even exist.

    Just in case my vision was faulty, I copy/pasted directly from the API listing, then double quoted it, did a replace substring to change (version) to 1.0

    "/d2l/api/gae/(version)/linkuser" → "/d2l/api/gae/1.0/linkuser"

    Then I compared this string with the string I had been using in my code "/d2l/api/gae/1.0/linkuser"
    They were identical. Is it possible for someone to verify that this is, in fact, the correct route for this? Maybe there is a typo?