4.4 KiB
oauth2
This endpoint allows clients to trade their client credentials for an Access Token that can be used on subsequent calls to our API. Example of usage:
curl -X POST -H \"Content-Type: application/x-www-form-urlencoded\" -d 'client_id=someId&scope=someScope&client_secret=someSecret&grant_type=client_credentials' 'https://api.thousandeyes.com/v7/oauth2/token'
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 7.0.2
- Package version: 1.0.0
- Generator version: 7.5.0
- Build package: com.thousandeyes.api.codegen.ThousandeyesPythonGenerator
Requirements.
Python 3.7+
Installation & Usage
pip install
If the python package is hosted on a repository, you can install directly using:
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)
Then import the package:
import oauth2
Setuptools
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install to install the package for all users)
Then import the package:
import oauth2
Tests
Execute pytest to run the tests.
Getting Started
Please follow the installation procedure and then run the following:
import oauth2
from oauth2.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.thousandeyes.com
# See configuration.py for a list of all supported configuration parameters.
configuration = oauth2.Configuration(
host = "https://api.thousandeyes.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
configuration.access_token = os.environ["ACCESS_TOKEN"]
# Enter a context with an instance of the API client
with oauth2.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = oauth2.DefaultApi(api_client)
x_tenant_id = 'x_tenant_id_example' # str | Tenant ID, only applicable if using the WanInsights Tenant flow (optional)
client_id = 'client_id_example' # str | The Application ID. (optional)
client_secret = 'client_secret_example' # str | The application secret that was generated for you during the app registration. The Basic auth pattern of instead providing credentials in the Authorization header, per RFC 6749 is also supported. (optional)
grant_type = 'grant_type_example' # str | Must be set to `client_credentials`. (optional)
scope = 'scope_example' # str | Requested scope values for the new access token. (optional)
thousandeyes_bearer_token = 'thousandeyes_bearer_token_example' # str | The user's bearer token, only applicable for special cases where the client wants to make requests on behalf of a user. (optional)
try:
# Create and return access token.
api_response = api_instance.v7_oauth2_token_post(x_tenant_id=x_tenant_id, client_id=client_id, client_secret=client_secret, grant_type=grant_type, scope=scope, thousandeyes_bearer_token=thousandeyes_bearer_token)
print("The response of DefaultApi->v7_oauth2_token_post:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->v7_oauth2_token_post: %s\n" % e)
Documentation for API Endpoints
All URIs are relative to https://api.thousandeyes.com
| Class | Method | HTTP request | Description |
|---|---|---|---|
| DefaultApi | v7_oauth2_token_post | POST /v7/oauth2/token | Create and return access token. |
Documentation For Models
Documentation For Authorization
Authentication schemes defined for the API:
application
- Type: OAuth
- Flow: application
- Authorization URL:
- Scopes:
- read: allows reading resources