Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pbansal
Test-Docker
Commits
2ec5fffc
Commit
2ec5fffc
authored
Jun 04, 2020
by
B13nch3n
Browse files
Create API token for non-priviledged user
parent
f0a3bc03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Docker/cathapi/entrypoint.sh
View file @
2ec5fffc
...
...
@@ -91,9 +91,10 @@ except:
END
# create a normal user to play with the API
>
&2
echo
"Create user for the API"
>
&2
echo
"Create user for the API
& Token
"
python3 manage.py shell
<<
END
from django.contrib.auth.models import User
from rest_framework.authtoken.models import Token
try:
User.objects.get(username='sib_ws5')
except User.DoesNotExist:
...
...
@@ -101,6 +102,7 @@ except User.DoesNotExist:
user.is_superuser=False
user.is_staff=False
user.save()
Token.objects.create(user=user, key='d76afaba0d07F19a9ad66bDb8e71024ce6f9a81f')
except Exception as dexc:
if str(dexc) == 'UNIQUE constraint failed: auth_user.username':
pass
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment