def POST(self): creds = json.loads(web.data()) username = None password = None passwd_creds = creds.get('passwordCredentials', None) if passwd_creds != None: username = creds.get('passwordCredentials').get('username', None) password = creds.get('passwordCredentials').get('password', None) tenant_id = creds.get('tenantID', None) tenant_name = creds.get('tenantName', None) token_id = creds.get('tokenID', None) keystone = identity.auth(usr=username, passwd=password, token_id=token_id, tenant_id=tenant_id, tenant_name=tenant_name, url=_endpoint, api="NATIVE") token = identity.get_token(keystone, usr=username, passwd=password, api="NATIVE", tenant_id=tenant_id, tenant_name=tenant_name, token_id=token_id) if token == -1: return web.webUnauthorized() auth_token = {} auth_token['token'] = token.id body = json.dumps(auth_token) web.header("Content-Type", "application/json") return body
def POST(self): creds = json.loads(web.data()) username = creds.get("passwordCredentials").get("username") password = creds.get("passwordCredentials").get("password") keystone = identity.auth(usr=username, passwd=password, url=_endpoint, api="NATIVE") token = identity.get_token(keystone, username, password, "NATIVE") if token == -1: return web.webUnauthorized() auth_token = {} auth_token["token"] = token.id body = json.dumps(auth_token) web.header("Content-Type", "application/json") return body
def _authenticate(self): """Get a new authentication token.""" identity_response = identity.auth_with_key(self.user, self.key) self.token = identity.get_token(identity_response) self.endpoint = identity.get_maas_endpoint(identity_response) self.headers.update({'X-Auth-Token': self.token})