Skip to content

Instantly share code, notes, and snippets.

@neverendingqs
Last active November 23, 2016 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neverendingqs/53a65896968c2b945110a14166092842 to your computer and use it in GitHub Desktop.
Save neverendingqs/53a65896968c2b945110a14166092842 to your computer and use it in GitHub Desktop.
Brightspace "whoami" using OAuth 2.0 access token
import requests # requests==2.7.0
url = "http://localhost:44453/d2l/api/lp/1.0/users/whoami"
access_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjBiOWU5Njg2LWRiYTctNDBkNS05MmRlLTYxNmVkNmYzZmJhMSJ9.eyJzdWIiOiIxNjkiLCJ0ZW5hbnRpZCI6IjNlZGE2ZTJhLWNmZjItNGE0OS1hZjQ5LWY4MmUzZWUzZTkxMSIsInNjb3BlIjoiY29yZToqOioiLCJqdGkiOiJlNDI0YjQyZi1hZTY5LTQ4ZGItYWUzMS00ZjhlZTQ1NDBkNmEiLCJpc3MiOiJodHRwczovL2FwaS5icmlnaHRzcGFjZS5jb20vYXV0aCIsImF1ZCI6Imh0dHBzOi8vYXBpLmJyaWdodHNwYWNlLmNvbS9hdXRoL3Rva2VuIiwiZXhwIjoxNDc5OTIxMTUxLCJuYmYiOjE0Nzk5MTc1NTF9.GznF7Wl-DQxJ3Qp7OPJ4PU_nhHzCzaHYcAFlgahLXyBhAqqAQWKYcrID8UB478iwL2ntYPCtJKLCsJp-ZzZ4QMNc0rwFSJ6_jpQ9W3ALYgIBhILuabG-Xkfdnv4Bi-ME4Q1RcNUvNuuP7ygaJtONc7S4hJtYagsmI9JOW46h-64nevDLijO4CJOIq9B27k_PjPzisAET0ziUD6swIvhX7rUz_nOmCWZJDP56Mi-LIMSd7GrTYP9dTnwvw_rmU_iliO8iOqSKtPaaYUBF9gK4Zulg93nNZDybZozM9sxlfvdRrnjDq6PPUCIbyG1zFwD3GH7-bE9HlemSElhuxyMqSg"
response = requests.get(url, headers={'authorization': "Bearer {}".format(access_token)})
print(response.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment