本文整理汇总了Python中openedx.core.djangoapps.credentials.models.CredentialsApiConfig.get_internal_api_url_for_org方法的典型用法代码示例。如果您正苦于以下问题:Python CredentialsApiConfig.get_internal_api_url_for_org方法的具体用法?Python CredentialsApiConfig.get_internal_api_url_for_org怎么用?Python CredentialsApiConfig.get_internal_api_url_for_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openedx.core.djangoapps.credentials.models.CredentialsApiConfig
的用法示例。
在下文中一共展示了CredentialsApiConfig.get_internal_api_url_for_org方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_credentials_api_client
# 需要导入模块: from openedx.core.djangoapps.credentials.models import CredentialsApiConfig [as 别名]
# 或者: from openedx.core.djangoapps.credentials.models.CredentialsApiConfig import get_internal_api_url_for_org [as 别名]
def get_credentials_api_client(user, org=None):
"""
Returns an authenticated Credentials API client.
Arguments:
user (User): The user to authenticate as when requesting credentials.
org (str): Optional organization to look up the site config for, rather than the current request
"""
jwt = create_jwt_for_user(user)
if org is None:
url = CredentialsApiConfig.current().internal_api_url # by current request
else:
url = CredentialsApiConfig.get_internal_api_url_for_org(org) # by org
return EdxRestApiClient(url, jwt=jwt)
示例2: get_credentials_api_client
# 需要导入模块: from openedx.core.djangoapps.credentials.models import CredentialsApiConfig [as 别名]
# 或者: from openedx.core.djangoapps.credentials.models.CredentialsApiConfig import get_internal_api_url_for_org [as 别名]
def get_credentials_api_client(user, org=None):
"""
Returns an authenticated Credentials API client.
Arguments:
user (User): The user to authenticate as when requesting credentials.
org (str): Optional organization to look up the site config for, rather than the current request
"""
scopes = ['email', 'profile']
expires_in = settings.OAUTH_ID_TOKEN_EXPIRATION
jwt = JwtBuilder(user).build_token(scopes, expires_in)
if org is None:
url = CredentialsApiConfig.current().internal_api_url # by current request
else:
url = CredentialsApiConfig.get_internal_api_url_for_org(org) # by org
return EdxRestApiClient(url, jwt=jwt)