def token(self, request):
    (client_id, client_secret) = self._get_api_client_credentials(request)
    if ((not client_id) or (not client_secret)):
        response = create_commercetools_response(request, status_code=401)
        return response
    if self.model.is_valid(client_id, client_secret):
        params = parse_qs(request.body)
        scope = params.get('scope', 'manage_project:todo')
        token = {'access_token': str(uuid.uuid4()), 'expires_in': self._expire_time, 'scope': scope, 'token_type': 'Bearer'}
        self.model.add_token(token)
        response = create_commercetools_response(request, json=token)
        return response
def token(self, request):
    (client_id, client_secret) = self._get_api_client_credentials(request)
    if ((not client_id) or (not client_secret)):
        response = create_commercetools_response(request, status_code=401)
        return response
    if self.model.is_valid(client_id, client_secret):
        params = parse_qs(request.body)
        scope = params.get('scope', 'manage_project:todo')
        token = {'access_token': str(uuid.uuid4()), 'expires_in': self._expire_time, 'scope': scope, 'token_type': 'Bearer'}
        self.model.add_token(token)
        response = create_commercetools_response(request, json=token)
        return response