Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
d907af3c
Commit
d907af3c
authored
Sep 25, 2018
by
David Haynes
🙆
Browse files
PoC with using tokens for API request
- woo
parent
31a70dee
Pipeline
#2983
passed with stage
in 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
go/go_ahead/src/GolinksList.jsx
View file @
d907af3c
...
...
@@ -13,7 +13,12 @@ class GolinksList extends React.Component {
componentDidMount
()
{
if
(
window
.
django
.
user
.
is_authenticated
==
"
True
"
)
{
fetch
(
"
/api/golinks
"
)
fetch
(
"
/api/golinks/
"
,
{
headers
:
{
"
Content-Type
"
:
"
application/json; charset=utf-8
"
,
Authorization
:
"
Token {props.token}
"
}
})
.
then
(
res
=>
res
.
json
())
.
then
(
result
=>
{
...
...
go/go_back/views.py
View file @
d907af3c
...
...
@@ -28,6 +28,7 @@ from .models import URL, RegisteredUser
from
django.contrib.auth.models
import
User
,
Group
from
rest_framework
import
viewsets
from
rest_framework
import
permissions
from
rest_framework.authentication
import
TokenAuthentication
from
.serializers
import
URLSerializer
class
URLPermission
(
permissions
.
BasePermission
):
...
...
@@ -42,6 +43,7 @@ class URLViewSet(viewsets.ModelViewSet):
"""
API endpoint that handles creation/read/update/deletion of URL objects.
"""
authentication_classes
=
(
TokenAuthentication
,
)
serializer_class
=
URLSerializer
permission_classes
=
(
URLPermission
,)
lookup_field
=
'short'
...
...
Write
Preview
Markdown
is supported
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