{"id":15010136,"url":"https://github.com/chrisapa/d2lvalence_elixir","last_synced_at":"2026-02-06T04:02:45.087Z","repository":{"id":57488086,"uuid":"385326647","full_name":"chrisapa/d2lvalence_elixir","owner":"chrisapa","description":"Elixir implementation of d2lvalence to connecto to the D2L Brightspace API","archived":false,"fork":false,"pushed_at":"2021-07-16T17:41:22.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T08:49:40.798Z","etag":null,"topics":["authentication","brightspace","d2l-elixir","d2lvalence","elixir"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisapa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-12T17:18:00.000Z","updated_at":"2025-05-30T00:21:12.000Z","dependencies_parsed_at":"2022-08-29T11:20:55.722Z","dependency_job_id":null,"html_url":"https://github.com/chrisapa/d2lvalence_elixir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chrisapa/d2lvalence_elixir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisapa%2Fd2lvalence_elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisapa%2Fd2lvalence_elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisapa%2Fd2lvalence_elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisapa%2Fd2lvalence_elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisapa","download_url":"https://codeload.github.com/chrisapa/d2lvalence_elixir/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisapa%2Fd2lvalence_elixir/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29149594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","brightspace","d2l-elixir","d2lvalence","elixir"],"created_at":"2024-09-24T19:30:39.110Z","updated_at":"2026-02-06T04:02:45.067Z","avatar_url":"https://github.com/chrisapa.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# D2lvalenceElixir\n\n## Desire2Learn Client Library for Elixir\n\nElixir implementation of d2lvalence to connecto to the Desire2Learn's Valence API.\n\nBased on [Desire2Learn Client Library for Python](https://github.com/Brightspace/valence-sdk-python)\n\nWorks with the [Brightspace Api Rest](https://docs.valence.desire2learn.com/reference.html)\n\n**Auth:** The D2lvalenceElixir.Auth module provides assistance for the authentication needed to invoke Valence APIs. You use the module's functiones to create a %D2lvalenceElixir.Auth.D2LUserContext{} struct that you can then employ as an authentication helper.\n\n**Service:** The D2lvalenceElixir.Utils.Service module provides many functions to call the Brightspace API Rest according to their documentation.\n\n## Installation\n\nThe package can be installed by adding `d2lvalence_elixir` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:d2lvalence_elixir, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Documentation\n\n[HexDocs](https://hexdocs.pm/d2lvalence_elixir)\n\n## Use\n\n### Authentication\n\n```elixir\ndefmodule D2lvalenceElixir.Examples.SimpleAuthentication do\n  alias D2lvalenceElixir.Auth.D2LAppContext\n  alias D2lvalenceElixir.Auth.D2LUserContext\n  alias D2lvalenceElixir.Auth.D2LUserContextSimple\n  alias D2lvalenceElixir.Auth\n\n  def get_url_to_authenticate(app_id, app_key) do\n    # You recieve the app_id and the app_key and then use the host\n    # of your Brightspace instance, the callback and True for SSL (https).\n    # You send the result URL to the user so he can authenticate and then\n    # you recieve the user_key and user_id in the callback url.\n    Auth.fashion_app_context(app_id: app_id, app_key: app_key)\n    |\u003e D2LAppContext.create_url_for_authentication(\n      \"bloqueneon.uniandes.edu.co\",\n      \"http://localhost:8080/token\",\n      true\n    )\n  end\n\n  def auth_token_handler(result_url, app_id, app_key) do\n    # You take the full result url (including https://yourfancyapp:8080/callback) requested after login and then generates the\n    # user_context than helps your application with all the authenticated requests to de Brightspace API\n    {:ok, full_user_context = %D2LUserContext{}} =\n      Auth.fashion_app_context(app_id: app_id, app_key: app_key)\n      |\u003e D2LAppContext.create_user_context(\n        result_uri: result_url,\n        host: \"bloqueneon.uniandes.edu.co\",\n        encrypt_requests: true\n      )\n\n    # {full_user_context, simple_user_context}. I recommend to store the simple_user_context on the session\n    # for security purposes (You must NOT share the app_id and app_key with the user)\n    {full_user_context, full_user_context |\u003e D2LUserContext.get_simple_user_context()}\n  end\n\n  def get_full_user_context(%D2LUserContextSimple{} = simple_user_context, app_id, app_key) do\n    # If you only stores the D2LUserContextSimple, you have to generate the full_user_context to\n    # make authenticated requests to the Brightspace API\n    {:ok, %D2LUserContext{} = full_user_context} =\n      Auth.fashion_app_context(app_id: app_id, app_key: app_key)\n      |\u003e D2LUserContext.get_full_user_context(simple_user_context)\n\n    full_user_context\n  end\nend\n```\n\n### Simple calls\n\n```elixir\ndefmodule D2lvalenceElixir.Examples.SimpleApiCalls do\n  alias D2lvalenceElixir.Auth.D2LUserContext\n  alias D2lvalenceElixir.Utils.Service\n  alias D2lvalenceElixir.Data.WhoAmIUser\n\n  def serializers do\n    # To encode and decode the requests, you could need some serializers.\n    # This function creates the map with the serializers you need.\n    # You need an application/json at least.\n    %{}\n    |\u003e Map.put(\"application/json\", Jason)\n  end\n\n  def whoami_api_call(%D2LUserContext{} = user_context) do\n    # With the user_context (full_user_context, not simple) you call the whoami\n    # You have to send the serializers, at least an application/json to decode the result\n    # I use this version because it works on my university\n    # The WhoAmI call shows who is the authenticated with the user_context\n    {:ok, user = %WhoAmIUser{}} =\n      user_context\n      |\u003e Service.get_whoami(serializers: serializers(), ver: \"1.23\")\n\n    user\n  end\n\n  def get_all_versions_api_call(%D2LUserContext{} = user_context) do\n    # With the user context, shows the information of all the products of the Brightspace instance\n    {:ok, products_information} =\n      user_context\n      |\u003e Service.get_all_versions(serializers: serializers(), ver: \"1.23\")\n\n    products_information\n  end\nend\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisapa%2Fd2lvalence_elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisapa%2Fd2lvalence_elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisapa%2Fd2lvalence_elixir/lists"}