本文整理汇总了Python中okta.framework.ApiClient.ApiClient类的典型用法代码示例。如果您正苦于以下问题:Python ApiClient类的具体用法?Python ApiClient怎么用?Python ApiClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ApiClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_session
def clear_session(self, id):
"""Terminate a session
:param id: the target session id
:rtype: Session
"""
ApiClient.delete_path(self, '/{0}'.format(id))
示例2: get_paged_users
def get_paged_users(self, limit=None, filter_string=None, after=None, url=None):
"""Get a paged list of Users
:param limit: maximum number of users to return
:type limit: int or None
:param filter_string: string to filter users
:type filter_string: str or None
:param after: user id that filtering will resume after
:type after: str
:param url: url that returns a list of User
:type url: str
:rtype: PagedResults of User
"""
if url:
response = ApiClient.get(self, url)
else:
params = {
'limit': limit,
'after': after,
'filter': filter_string
}
response = ApiClient.get_path(self, '/', params=params)
return PagedResults(response, User)
示例3: get_paged_events
def get_paged_events(self, limit=None, start_date=None, after=None, filter_string=None, url=None):
"""Get a paged list of Events
:param limit: maximum number of events to return
:type limit: int or None
:param filter_string: string to filter events
:type filter_string: str or None
:param after: event id that filtering will resume after
:type after: str or None
:param url: url that returns a list of Event
:type url: str or None
:rtype: PagedResults of Event
"""
if url:
response = ApiClient.get(self, url)
else:
params = {
'limit': limit,
'startDate': start_date,
'after': after,
'filter': filter_string
}
response = ApiClient.get_path(self, '/', params=params)
return PagedResults(response, Event)
示例4: deactivate_app_instance
def deactivate_app_instance(self, id):
"""Deactivate app by target id
:param id: the target app id
:type id: str
:return: None
"""
ApiClient.post_path(self, '/{0}/lifecycle/deactivate'.format(id), None)
示例5: delete_app_instance
def delete_app_instance(self, id):
"""Delete app by target id
:param id: the target app id
:type id: str
:return: None
"""
ApiClient.delete_path(self, '/{0}'.format(id))
示例6: reset_factor
def reset_factor(self, user_id, user_factor_id):
"""Reset an enrolled factor
:param user_id: target user id
:type user_id: str
:param user_factor_id: target factor id
:type user_factor_id: str
:rtype: None
"""
ApiClient.delete_path(self, '/{0}/factors/{1}'.format(user_id, user_factor_id))
示例7: enroll_factor
def enroll_factor(self, state_token, factor_type, provider, profile, relay_state=None):
"""Enroll in an MFA factor during the auth flow. Usually only encountered if MFA is required for authentication
:param state_token: current state token from the previous AuthResult
:type state_token: str
:param factor_type: type of factor (sms, token, question, token:software:totp, token:hardware etc)
:type factor_type: str
:param provider: factor provider (OKTA, RSA, SYMANTEC, GOOGLE etc)
:type provider: str
:param profile: factor profile that depends on the factor type
:type profile: FactorProfile
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:rtype: AuthResult
"""
request = {
'stateToken': state_token,
'factorType': factor_type,
'provider': provider,
'profile': profile,
'relayState': relay_state
}
response = ApiClient.post_path(self, '/factors', request)
return Utils.deserialize(response.text, AuthResult)
示例8: auth_with_factor
def auth_with_factor(self, state_token, factor_id, passcode,
relay_state=None, remember_device=None):
"""Continue authentication with an MFA attempt
:param state_token: current state token from the previous AuthResult
:type state_token: str
:param factor_id: target factor id
:type factor_id: str
:param passcode: passcode required for authenticating the factor
:type passcode: str
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:param remember_device: whether to remember this device to avoid requiring MFA next time
:type remember_device: bool
:rtype: AuthResult
"""
request = {
'stateToken': state_token,
'passCode': passcode,
'relayState': relay_state
}
params = {
'rememberDevice': remember_device
}
response = ApiClient.post_path(self, '/factors/{0}/verify'.format(factor_id),
request, params=params)
return Utils.deserialize(response.text, AuthResult)
示例9: verify_factor
def verify_factor(self, user_id, user_factor_id, activation_token=None, answer=None, passcode=None, next_passcode=None):
"""Verify an enrolled factor
:param user_id: target user id
:type user_id: str
:param user_factor_id: target factor id
:type user_factor_id: str
:param activation_token: token required for activation
:type activation_token: str
:param answer: answer usually required for a question factor
:type answer: str
:param passcode: code required for verification
:type passcode: str
:param next_passcode: code usually required for TOTP
:type next_passcode: str
:return:
"""
request = {
'activationToken': activation_token,
'answer': answer,
'passCode': passcode,
'nextPassCode': next_passcode
}
response = ApiClient.post_path(self, '/{0}/factors/{1}/verify'.format(user_id, user_factor_id), request)
return Utils.deserialize(response.text, FactorVerificationResponse)
示例10: authenticate
def authenticate(self, username, password,
relay_state=None, response_type=None, force_mfa=None, context=None):
"""Begin the authentication process with a username and password
:param username: user's username
:type username: str
:param password: user's password
:type password: str
:param relay_state: data that will persist for the lifetime of the authentication or recovery token
:type relay_state: str or None
:param response_type: the type of session to return (session_token or session_token_url usually)
:type response_type: str
:param force_mfa: whether to force mfa even if the auth is exempt
:type force_mfa: bool
:param context: contextual info about the auth request like ip and location
:type context: Context
:rtype: AuthResult
"""
request = {
'username': username,
'password': password,
'relayState': relay_state,
'context': context
}
params = {
'force_mfa': force_mfa,
'response_type': response_type
}
response = ApiClient.post_path(self, '/', request, params=params)
return Utils.deserialize(response.text, AuthResult)
示例11: expire_password
def expire_password(self, uid, temp_password=False):
"""Expire user's password by target user id
:param uid: the target user id
:type uid: str
:param temp_password: whether a temporary password should be set
:type temp_password: bool
:return: None or TempPassword
"""
if not temp_password:
response = ApiClient.post_path(self, '/{0}/lifecycle/expire_password'.format(uid))
else:
params = {
'tempPassword': temp_password
}
response = ApiClient.post_path(self, '/{0}/lifecycle/expire_password'.format(uid), params=params)
return Utils.deserialize(response.text, TempPassword)
示例12: validate_session
def validate_session(self, id):
"""Validate a session
:param id: the target session id
:rtype: Session
"""
response = ApiClient.get_path(self, '/{0}'.format(id))
return Utils.deserialize(response.text, Session)
示例13: create_user
def create_user(self, user, activate=None):
"""Create a user
:param user: the data to create a user
:type user: User
:param activate: whether to activate the user
:type activate: bool
:rtype: User
"""
if activate is None:
response = ApiClient.post_path(self, '/', user)
else:
params = {
'activate': activate
}
response = ApiClient.post_path(self, '/', user, params=params)
return Utils.deserialize(response.text, User)
示例14: extend_session
def extend_session(self, id):
"""Extend a session's lifespan
:param id: the target session id
:rtype: Session
"""
response = ApiClient.put_path(self, '/{0}'.format(id), None)
return Utils.deserialize(response.text, Session)
示例15: create_group
def create_group(self, group):
"""Create a group
:param group: the data to create a group
:type group: UserGroup
:rtype: UserGroup
"""
response = ApiClient.post_path(self, '/', group)
return Utils.deserialize(response.text, UserGroup)