#NEWLINE# def token_auth( token , project_id = None , project_name = None , project_domain_name = 'Default' ) : #NEWLINE# #INDENT# 'Return a token auth plugin object.\n\n    :param token: the token to use for authentication.\n\n    :param project_id: the project(ex. tenant) id to scope the auth.\n\n    :returns: a token auth plugin object.\n    ' #NEWLINE# token_kwargs = dict ( auth_url = base . retrieve_auth_url ( CONF . keystone . endpoint_type ) , token = token ) #NEWLINE# if CONF . use_identity_api_v3 : #NEWLINE# #INDENT# token_kwargs . update ( dict ( project_id = project_id , project_name = project_name , project_domain_name = project_domain_name ) ) #NEWLINE# auth = keystone_identity . v3 . Token ( ** token_kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# token_kwargs . update ( dict ( tenant_id = project_id , tenant_name = project_name ) ) #NEWLINE# auth = keystone_identity . v2 . Token ( ** token_kwargs ) #NEWLINE# #UNINDENT# return auth