def get_api_client(api_config, student):
 client_name = api_config.OAUTH2_CLIENT_NAME
 try:
  client = Client.objects.get(name=client_name)
 except Client.DoesNotExist:
  raise ImproperlyConfigured('OAuth2 Client with name [{}] does not exist.'.format(client_name))
 scopes = ['email', 'profile']
 expires_in = settings.OAUTH_ID_TOKEN_EXPIRATION
 jwt = JwtBuilder(student, secret=client.client_secret).build_token(scopes, expires_in, aud=client.client_id)
 return EdxRestApiClient(api_config.internal_api_url, jwt=jwt)

def get_api_client ( api_config , student ) : client_name = api_config . OAUTH2_CLIENT_NAME try : client = Client . objects . get ( name = client_name ) except Client . DoesNotExist : raise ImproperlyConfigured ( 'OAuth2 Client with name [{}] does not exist.' . format ( client_name ) ) scopes = [ 'email' , 'profile' ] expires_in = settings . OAUTH_ID_TOKEN_EXPIRATION jwt = JwtBuilder ( student , secret = client . client_secret ) . build_token ( scopes , expires_in , aud = client . client_id ) return EdxRestApiClient ( api_config . internal_api_url , jwt = jwt )
create and configure an api client for authenticated http requests .