Skip to content

Latest commit

 

History

History
96 lines (65 loc) · 4 KB

File metadata and controls

96 lines (65 loc) · 4 KB

cyperf.AuthorizationApi

All URIs are relative to http://localhost

Method HTTP request Description
authenticate POST /auth/realms/keysight/protocol/openid-connect/token

authenticate

Authenticate200Response authenticate(client_id=client_id, grant_type=grant_type, password=password, refresh_token=refresh_token, scope=scope, username=username)

Get an access_token and refresh_token with a username+password, or use a refresh_token to generate a new access_token. You can also get a refresh_token from the UI, from Gear Menu > Administration > Offline Tokens. The access_token should be supplied in the Authorization header for all API requests.

Example

  • OAuth Authentication (OAuth2):
  • OAuth Authentication (OAuth2):
import cyperf
from cyperf.models.authenticate200_response import Authenticate200Response
from cyperf.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cyperf.Configuration(
    host = "http://localhost"
)

# 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.refresh_token = os.environ["OFFLINE_TOKEN_FROM_CYPERF_UI"]

configuration.refresh_token = os.environ["OFFLINE_TOKEN_FROM_CYPERF_UI"]

# Enter a context with an instance of the API client
with cyperf.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cyperf.AuthorizationApi(api_client)
    client_id = 'client_id_example' # str |  (optional)
    grant_type = 'grant_type_example' # str | Controls the type of credentials to be used for authentication. (optional)
    password = 'password_example' # str | (only for grant_type: password) The password to use. (optional)
    refresh_token = 'refresh_token_example' # str | (only for grant_type: refresh_token) The refresh token. You can obtain this from Gear Menu > Administration > Offline Tokens. (optional)
    scope = 'scope_example' # str |  (optional)
    username = 'username_example' # str | (only for grant_type: password) The username to use. (optional)

    try:
        api_response = api_instance.authenticate(client_id=client_id, grant_type=grant_type, password=password, refresh_token=refresh_token, scope=scope, username=username)
        print("The response of AuthorizationApi->authenticate:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling AuthorizationApi->authenticate: %s\n" % e)

Parameters

Name Type Description Notes
client_id str [optional]
grant_type str Controls the type of credentials to be used for authentication. [optional]
password str (only for grant_type: password) The password to use. [optional]
refresh_token str (only for grant_type: refresh_token) The refresh token. You can obtain this from Gear Menu > Administration > Offline Tokens. [optional]
scope str [optional]
username str (only for grant_type: password) The username to use. [optional]

Return type

Authenticate200Response

Authorization

OAuth2, OAuth2

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A new token. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]