The edX REST API Client simplifies communicating with other Open edX services by providing OAuth2 and JWT utilities.
In a Python 3.8 virtual environment:
$ make requirements
$ make validate
Open edX services, including LMS, should use the OAuthAPIClient
class to make OAuth2 client requests and REST API calls.
By default the OAuthAPIClient
object can be used like any requests.Session object and you can follow the docs that the requests library provides.
The OAuthAPIClient
sessions makes some extra requests to get access tokens from the auth endpoints. These requests have a default timeout that can be overridden by passing in a timeout
parameter when instantiating the OAuthAPIClient
object.
# create client with default timeouts for token retrieval
client = OAuthAPIClient('https://lms.root', 'client_id', 'client_secret')
# create client, overriding default timeouts for token retrieval
client = OAuthAPIClient('https://lms.root', 'client_id', 'client_secret', timeout=(6.1, 2))
client = OAuthAPIClient('https://lms.root', 'client_id', 'client_secret',
timeout=(REQUEST_CONNECT_TIMEOUT, 3)
)
# for a request to some.url, a separate timeout should always be set on your requests
client.get('https://some.url', timeout=(3.1, 0.5))
The value of the timeout
setting is the same as for any request made with the requests
library. See the Requests timeouts documentation for more details.
The OAuthAPIClient uses the TieredCache internally for caching. Read more about the requirements of TieredCache, which include Django caching and some custom middleware.
Contributions are very welcome. Please read How To Contribute for details.
This project is currently accepting all types of contributions, bug fixes, security fixes, maintenance work, or new features. However, please make sure to have a discussion about your new feature idea with the maintainers prior to beginning development to maximize the chances of your change being accepted. You can start a conversation by creating a new issue on this repo summarizing your idea.
If you're having trouble, we have discussion forums at discuss.openedx.org where you can connect with others in the community.
Our real-time conversations are on Slack. You can request a Slack invitation, then join our community Slack workspace.
For anything non-trivial, the best path is to open an issue in this repository with as many details about the issue you are facing as you can provide.
For more information about these options, see the Getting Help page.
All community members are expected to follow the Open edX Code of Conduct.
Please do not report security issues in public. Please email [email protected].