oauth2_user_code

The following methods allow for interaction with the ZPA OAuth2 User Code Controller API endpoints.

Methods are accessible via zpa.oauth2_user_code

Copyright (c) 2023, Zscaler Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

class OAuth2UserCodeAPI

Bases: APIClient

A Client object for the OAuth2 User Code resource.

add_provisioning_key(key_type, **kwargs)

Adds a new Provisioning Key for the specified customer.

Parameters:

key_type (str) – The type of provisioning key, accepted values are: connector, service_edge, assistant_group, and site_controller_group.

Keyword Arguments:
  • user_codes (list[str]) – List of user codes associated with the provisioning key.

  • component_group_id (int, optional) – The unique identifier of the component group.

  • config_cloud_name (str, optional) – The cloud name for the configuration.

  • enrollment_server (str, optional) – The enrollment server URL.

  • nonce_association_type (str, optional) – The nonce association type (e.g., ASSISTANT_GRP).

  • tenant_id (int, optional) – The unique identifier of the tenant.

  • zcomponent_id (int, optional) – The unique identifier of the Zscaler component.

  • microtenant_id (str, optional) – The microtenant ID if applicable.

Returns:

A tuple containing (OAuth2UserCode instance, Response, error).

Return type:

Tuple

Examples

>>> new_prov_key, _, err = client.zpa.oauth2_user_code.add_provisioning_key(
...     key_type='connector',
...     user_codes=['code1', 'code2']
... )
... if err:
...     print(f"Error adding provisioning key: {err}")
...     return
... print(f"Provisioning key added successfully: {new_prov_key.as_dict()}")
verify_oauth2_user_code(key_type, **kwargs)

Verifies the provided list of user codes for a given component provisioning.

Parameters:

key_type (str) – The type of provisioning key, accepted values are: connector, service_edge, assistant_group, and site_controller_group.

Keyword Arguments:
  • user_codes (list[str]) – List of user codes to verify.

  • component_group_id (int, optional) – The unique identifier of the component group.

  • config_cloud_name (str, optional) – The cloud name for the configuration.

  • enrollment_server (str, optional) – The enrollment server URL.

  • nonce_association_type (str, optional) – The nonce association type (e.g., ASSISTANT_GRP).

  • tenant_id (int, optional) – The unique identifier of the tenant.

  • zcomponent_id (int, optional) – The unique identifier of the Zscaler component.

  • microtenant_id (str, optional) – The microtenant ID if applicable.

Returns:

A tuple containing (OAuth2UserCode instance, Response, error).

Return type:

Tuple

Examples

>>> verified_codes, _, err = client.zpa.oauth2_user_code.verify_oauth2_user_code(
...     key_type='connector',
...     user_codes=['code1', 'code2', 'code3']
... )
... if err:
...     print(f"Error verifying user codes: {err}")
...     return
... print(f"User codes verified successfully: {verified_codes.as_dict()}")
simplify_key_type(key_type)

Simplifies the key type for the user. Accepted values are ‘connector’ and ‘service_edge’.

Parameters:

key_type (str) – The key type provided by the user.

Returns:

The simplified key type.

Return type:

str