diff --git a/endpoints/api/trigger.py b/endpoints/api/trigger.py index 564bbd618..57189be8d 100644 --- a/endpoints/api/trigger.py +++ b/endpoints/api/trigger.py @@ -207,24 +207,25 @@ class BuildTriggerActivate(RepositoryParamResource): # Update the config. new_config_dict = request.get_json()['config'] - token_name = 'Build Trigger: %s' % trigger.service.name - token = model.create_delegate_token(namespace, repository, token_name, - 'write') + write_token_name = 'Build Trigger: %s' % trigger.service.name + write_token = model.create_delegate_token(namespace, repository, write_token_name, + 'write') try: path = url_for('webhooks.build_trigger_webhook', trigger_uuid=trigger.uuid) - authed_url = _prepare_webhook_url(app.config['PREFERRED_URL_SCHEME'], '$token', token.code, + authed_url = _prepare_webhook_url(app.config['PREFERRED_URL_SCHEME'], + '$token', write_token.code, app.config['SERVER_HOSTNAME'], path) final_config, trigger.private_key = handler.activate(trigger.uuid, authed_url, trigger.auth_token, new_config_dict) except TriggerActivationException as exc: - token.delete_instance() + write_token.delete_instance() raise request_error(message=exc.message) # Save the updated config. trigger.config = json.dumps(final_config) - trigger.write_token = token + trigger.write_token = write_token trigger.save() # Log the trigger setup.