Coverage for api/examples/oauth2_requests.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 06:14 +0000

1from api.examples.environment import ORIGIN, TOKEN 

2 

3 

4auth = f'-H "Authorization: Bearer {TOKEN}"' if TOKEN else "" 

5 

6auth_register_curl = f""" 

7# Register for a key 

8curl \\ 

9 -X POST \\ 

10 -H "Content-Type: application/json" \\ 

11 -d '{{"name": "My amazing project", "description": "To access Openverse API", "email": "user@example.com"}}' \\ 

12 "{ORIGIN}/v1/auth_tokens/register/" 

13""" # noqa: E501 

14 

15auth_token_curl = f""" 

16# Get an access token token 

17curl \\ 

18 -X POST \\ 

19 -H "Content-Type: application/x-www-form-urlencoded" \\ 

20 -d 'grant_type=client_credentials&client_id=<Openverse API client ID>&client_secret=<Openverse API client secret>' \\ 

21 "{ORIGIN}/v1/auth_tokens/token/" 

22""" # noqa: E501 

23 

24auth_key_info_curl = f""" 

25curl \\ 

26 {auth} \\ 

27 "{ORIGIN}/v1/rate_limit/" 

28"""