def authenticate_api(self, **kwargs):
"""
Call a sample Wistia API url to check on authentication success.
Reference:
https://wistia.com/doc/data-api#authentication
Arguments:
kwargs (dict): Wistia master token key-value pair.
Returns:
auth_data (dict): Master token, provided by a user, which is to be stored in Wistia's player metadata.
error_status_message (str): Message with authentication outcomes for the sake of verbosity.
"""
token, media_id = kwargs.get('token'), kwargs.get('video_id') # pylint: disable=unused-variable
auth_data, error_message = {}, ''
auth_data['token'] = token
url = self.captions_api.get('auth_sample_url').format(token=str(token))
response = requests.get('https://' + url)
if response.status_code == httplib.UNAUTHORIZED:
error_message = "Authentication failed. " \
"Please ensure you have provided a valid master token, using Video API Token field."
return auth_data, error_message
评论列表
文章目录