Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust on generate_api_example to new way to get auth token on Taiga. #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from taiga.external_apps.models import Application, ApplicationToken
from taiga.webhooks.models import Webhook
from taiga.users.models import User
from taiga.auth.tokens import get_token_for_user
from taiga.auth.tokens import CancelToken
from taiga.projects.epics.models import RelatedUserStory
from taiga.projects.models import Project, Membership
from taiga.projects.notifications.models import NotifyPolicy
Expand Down Expand Up @@ -2731,7 +2731,7 @@
"method": "POST",
"url": "/api/v1/users/cancel",
"body": {
"cancel_token": get_token_for_user(user, "cancel_account")
"cancel_token": str(CancelToken.for_user(user))
}
}),
("importers-trello-auth-url", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.db import connection

from taiga.users.models import User
from taiga.auth.tokens import get_token_for_user
from taiga.auth.tokens import AccessToken

from ._requests_data import USER_ID, reqs as _reqs

Expand Down Expand Up @@ -72,13 +72,12 @@ def _execute_requests(self, reqs):
user.new_email = "[email protected]"
user.save()

user_token = get_token_for_user(user, "authentication")
admin_token = get_token_for_user(admin, "authentication")
user_token = str(AccessToken.for_user(user))
admin_token = str(AccessToken.for_user(admin))
os.environ["AUTH_TOKEN"] = user_token
os.environ["ADMIN_AUTH_TOKEN"] = admin_token

host = "http://localhost:8000"

for (key, req) in reqs.items():
print("Generate", key)

Expand Down Expand Up @@ -110,7 +109,10 @@ def _execute_requests(self, reqs):
if result.stdout == b'':
response_data = None
else:
response_data = json.loads(result.stdout.decode('utf-8'))
try:
response_data = json.loads(result.stdout.decode('utf-8'))
except Exception as e:
print("ERROR on key: ", key)
if req.get('index', None) is not None:
response_data = response_data[req['index']]

Expand Down