def test_signin__unknown_user__return_bad_request(): # arrange client = APIRequestFactory() data = { 'username': '******', 'password': '******', } view = ObtainAuthToken.as_view() request = client.post( '/api/v1/signin/', data=data, format='json', ) # act response = view(request) # assert assert response.status_code == 400
def test_signin__proper_call__return_token(): # arrange CustomUser.objects.create_user( email='*****@*****.**', password='******', ) client = APIRequestFactory() data = { 'username': '******', 'password': '******', } view = ObtainAuthToken.as_view() request = client.post( '/api/v1/signin/', data=data, format='json', ) # act response = view(request) # assert assert response.status_code == 200 assert 'token' in response.data.keys()
from django.urls import include, path from rest_framework.authtoken.views import ObtainAuthToken from rest_framework.routers import DefaultRouter from . import views router = DefaultRouter() router.register("notes", views.NoteViewSet) router.register("tags", views.TagViewSet) router.register("sync", views.SyncViewSet, basename="Sync") urlpatterns = [ path("", include(router.urls)), path("auth/", include("rest_framework.urls")), path("token/", ObtainAuthToken.as_view()), ]
schema_view = get_schema_view( openapi.Info( title="Snippets API", default_version='v1', description= "Learn about all the endpoints and their required parameters", contact=openapi.Contact(email="*****@*****.**"), license=openapi.License(name="BSD License"), ), public=True, permission_classes=(permissions.AllowAny, ), ) urlpatterns = [ path('register-user', views.RegisterUser.as_view(), name='register-user'), path('login', ObtainAuthToken.as_view(), name='login-using-token'), path('logout', views.Logout.as_view(), name='logout'), path('update-user-profile/<int:pk>', views.UpdateUserProfile.as_view(), name='update-user-profile'), path('list-users', views.ListUsers.as_view(), name='list-users'), path('user-details/<int:pk>', views.GetUserDetail.as_view(), name='user-details'), path('add-friend', views.AddFriend.as_view(), name='add-friend'), path('remove-friend', views.RemoveFriend.as_view(), name='remove-friend'), path('swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'), path('swagger', schema_view.with_ui('swagger', cache_timeout=0),
from django.urls import include, path from rest_framework import routers from rest_framework.authtoken.views import ObtainAuthToken from . import views router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ path('api-auth/', ObtainAuthToken.as_view()), path('', include(router.urls)), path('getToken/', ObtainAuthToken.as_view()) # include('rest_framework.urls', namespace='rest_framework' ]
from django.contrib import admin from django.urls import path,include from rest_framework.urlpatterns import format_suffix_patterns from rest_framework.authtoken.views import ObtainAuthToken from api.views import ( CoursesView, UserMyView, UserView, CourseUserView, LoginView, LogoutView, MessageView, ) from django.views.decorators.csrf import csrf_exempt urlpatterns = [ path('rest-auth/login/',ObtainAuthToken.as_view()), path('auth/login/',csrf_exempt(LoginView.as_view())), path('auth/logout/<str:token>/',csrf_exempt(LogoutView.as_view())), path('courses/<str:token>/',csrf_exempt(CoursesView.as_view())), path('usermy/<str:token>/',csrf_exempt(UserMyView.as_view())), path('user/<str:token>/',csrf_exempt(UserView.as_view())), path('user/<int:pk>/<str:username>/<str:token>/',csrf_exempt(CourseUserView.as_view())), path('messages/<int:pk>/<str:token>/',csrf_exempt(MessageView.as_view())), ] urlpatterns = format_suffix_patterns(urlpatterns)
from django.conf.urls import * from django.conf.urls.static import static from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.generic import RedirectView, TemplateView from rest_framework.authtoken.views import ObtainAuthToken from .views import EntryEndpoint, EntryListEndpoint, UserEndpoint, UserRegistrationEndpoint admin.autodiscover() urlpatterns = patterns('', url(r'^$', TemplateView.as_view(template_name='home.html')), url(r'^admin/', include(admin.site.urls)), url(r'^favicon.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'favicon.ico')), url(r'^login/?$', ObtainAuthToken.as_view(), name='login'), url(r'^register/?$', UserRegistrationEndpoint.as_view(), name='register'), url(r'^users/?$', UserEndpoint.as_view(), name='user'), url(r'^entries/?$', EntryListEndpoint.as_view(), name='entry'), url(r'^entries/(?P<pk>\d+)/?$', EntryEndpoint.as_view(), name='entry'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), ) urlpatterns += staticfiles_urlpatterns() + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
#from rest_framework import routers from cupones.views import CuponAPIView, CuponAfiliadoAPIView, UsuariosCuponesDisponibles, CuponDetailAPIView, CuponPopularAPIView from promociones.views import PromocionAPIView, PromocionAfiliadoAPIView, PromocionPopularAPIView from rest_framework.urlpatterns import format_suffix_patterns #router = routers.DefaultRouter() #router.register(r'afiliados', AfiliadoViewSet.as_view()) #router.register(r'users', UserViewSet) #router.register(r'grupos', GroupViewSet) urlpatterns = patterns('', # Examples: # url(r'^$', 'mypromo.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^api/iniciar-sesion/$', 'userprofiles.views.iniciar_sesion'), url(r'^api/auth-token/$', ObtainAuthToken.as_view()), url(r'^api/signup/$', SignupAPIView), url(r'^api/cambiar-clave/$', 'userprofiles.views.cambiar_clave'), url(r'^api/afiliados/$', AfiliadoAPIView.as_view()), url(r'^api/afiliados/(?P<pk>[0-9]+)/$', AfiliadoDetailAPIView.as_view()), #url(r'^api/afiliados-cupones-promociones/(?P<usuario>[0-9]+)/$', AfiliadoCuponesPromocionesAPIView), url(r'^api/afiliados-cupones/$', AfiliadoCuponesAPIView.as_view()), url(r'^api/afiliados-promociones/$', AfiliadoPromocionesAPIView.as_view()), url(r'^api/afiliados-carteles/$', AfiliadoCartelAPIView.as_view()), url(r'^api/locales/(?P<local_afiliado>[0-9]+)/$', LocalAfiliadoAPIView.as_view()), url(r'^api/cupones/$', CuponAPIView.as_view()), url(r'^api/cupon-popular/$', CuponPopularAPIView), url(r'^api/cupones/(?P<cupon_afiliado>[0-9]+)/$', CuponAfiliadoAPIView.as_view()), url(r'^api/cupones-detail/(?P<pk>[0-9]+)/$', CuponDetailAPIView.as_view(), name='cupon_detail_api'), url(r'^api/cupones-disponibles/(?P<usuario>[0-9]+)/$', UsuariosCuponesDisponibles.as_view()), url(r'^api/afiliados-disponibles/(?P<usuario>[0-9]+)/$', UsuariosCuponesAfiliados.as_view()),
msg = _('User account is disabled.') raise exceptions.ValidationError(msg) else: msg = _('Unable to log in with provided credentials.') raise exceptions.ValidationError(msg) else: msg = _('Must include "email" and "password".') raise exceptions.ValidationError(msg) attrs['user'] = user return attrs class ObtainAuthToken(ObtainAuthToken): serializer_class = TokenSerializer renderer_classes = (renderers.JSONRenderer,) def get(self, request): #TODO: render a view return Response() def post(self, request): serializer = self.serializer_class(data=request.DATA) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, create = Token.objects.get_or_create(user=user) return Response({ 'token': token.key }) obtain_auth_token = ObtainAuthToken.as_view()
from django.conf.urls import patterns, include, url from rest_framework.authtoken.views import ObtainAuthToken from .views import SessionLoginView, CurrentUserView, WishItemViewSet, CartItemViewSet from rest_framework.routers import SimpleRouter router = SimpleRouter() router.register(r'wishes', WishItemViewSet, base_name='wishes') router.register(r'cart', CartItemViewSet, base_name='cart') urlpatterns = patterns('', url(r'^token-auth/$', ObtainAuthToken.as_view()), url(r'^session-auth/$', SessionLoginView.as_view()), url(r'^me/$', CurrentUserView.as_view()), url(r'^', include(router.urls)), )
from django.urls import path from authapp.views import Access, Details from rest_framework.authtoken.views import ObtainAuthToken urlpatterns = [ path('auth-token', ObtainAuthToken.as_view()), path('access', Access.as_view()), path('details', Details.as_view()), ]
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url from django.contrib import admin from rest_framework import routers from rest_framework.authtoken.views import ObtainAuthToken from stats.views import CompanyViewset, SlotViewset router = routers.DefaultRouter() router.register(r'api/v1/company', CompanyViewset, base_name='company') router.register(r'api/v1/slot', SlotViewset, base_name='slot') urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api/auth_token', ObtainAuthToken.as_view()), ] urlpatterns += router.urls
def post(self, request): serializer = AuthTokenSerializer(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, created = Token.objects.get_or_create(user=user) utc_now = datetime.datetime.utcnow() if not created and token.created < utc_now - datetime.timedelta(hours=24): token.delete() token = Token.objects.create(user=serializer.object['user']) token.created = datetime.datetime.utcnow() token.save() return Response({'token': token.key}) F5_ObtainAuthToken = ObtainAuthToken.as_view() class ObtainExpiringAuthToken(ObtainAuthToken): def post(self, request): serializer = self.serializer_class(data=request.DATA) if serializer.is_valid(): token, created = Token.objects.get_or_create(user=serializer.object['user']) utc_now = datetime.datetime.utcnow() if not created and token.created < utc_now - datetime.timedelta(hours=24): token.delete() token = Token.objects.create(user=serializer.object['user']) token.created = datetime.datetime.utcnow() token.save()
include("django_cyverse_auth.urls", namespace="django_cyverse_auth") ), # API Layer endpoints url(r'^api/', include("api.urls", namespace="api")), # v2 API auth by token url(r'^auth$', Authentication.as_view(), name='token-auth'), # DRF API Login/Logout url( r'^api-auth/', include('rest_framework.urls', namespace='rest_framework') ), # Token login (Used internally by DRF?) url(r'^api-token-auth/', ObtainAuthToken.as_view()), # DB Admin Panel for admin users url(r'^admin/', include(admin.site.urls)) ] if settings.DEBUG and 'debug_toolbar.middleware.DebugToolbarMiddleware' in settings.MIDDLEWARE_CLASSES: try: import debug_toolbar urlpatterns += (url(r'^__debug__/', include(debug_toolbar.urls)), ) except ImportError: pass urlpatterns += staticfiles_urlpatterns()
from rest_framework.authtoken import views from django.conf.urls import url, include from rest_framework.routers import DefaultRouter from .views import UserViewSet, LogoutView, CurrentUserView from rest_framework.authtoken.views import ObtainAuthToken router = DefaultRouter() router.register(r'users', UserViewSet, 'users') urlpatterns = [ url(r'', include(router.urls, namespace='users')), url(r'login/$', ObtainAuthToken.as_view(), name="login-api"), url(r'logout/$', LogoutView.as_view(), name="logout-api"), url(r'current-user/$', CurrentUserView.as_view(), name="current-user-api") ]
from django.urls import path # from django.conf.urls import url from . import views from rest_framework.authtoken.views import ObtainAuthToken app_name = 'news-api' urlpatterns = [ # Login Section path('login/', ObtainAuthToken.as_view(), name='login'), # News Section path('news/new/', views.NewsCreateAPIView.as_view(), name='create_news'), path('news/edit/<int:pk>/', views.NewsUpdateAPIView.as_view(), name='edit_news'), path('news/', views.NewsListAPIView.as_view(), name='list_news'), path('news/<int:pk>/', views.NewsDetailAPIView.as_view(), name='news_details'), path('news/delete/<int:pk>/', views.DeleteNewsView, name='delete_news'), # Offers Section path('offers/new/', views.OffersCreateAPIView.as_view(), name='create_offer'), path('offers/edit/<int:pk>/', views.OffersUpdateAPIView.as_view(), name='edit_offer'), path('offers/', views.OffersListAPIView.as_view(), name='list_offers'), path('offers/<int:pk>/', views.OffersDetailAPIView.as_view(),
url(r'^add/permissions/$', AddPermissionView.as_view(), name='add_permissions'), url(r'^posts/$', posts, name='posts'), url(r'^posts/(?P<pk>\d+)/$', post_detail, name='post_detail'), # I dont want to have multiple classess for handling details and list separately so I'll change the route accordingly url(r'^cposts/$', PostsApiView.as_view(), name='class_posts_api'), url(r'^cposts/(?P<pk>\d+)/$', PostsApiView.as_view(), name='class_post_details_api'), url(r'^gposts/$', PostsGenericView.as_view(), name='generic_posts_get'), url(r'^gposts/(?P<pk>\d+)/$', PostsGenericView.as_view(), name='generic_post_detail'), # but they may be cases where we want to have our own LoginView url(r'^auth/login/$', ObtainAuthToken.as_view(), name='auth_token_view'), # custom auth token login and logout url(r'^auth/me/login/$', LoginApiView.as_view(), name='login_api'), url(r'^auth/me/logout/$', LogoutApiView.as_view(), name='logout_api'), url(r'^auth/token/$', TokenObtainPairView.as_view(), name='jwt_token_fetch'), url(r'^auth/token/refresh/$', TokenRefreshView.as_view(), name='jwt_refresh_fetch'), url(r'^user/posts/$', UserPosts.as_view(), name='user_posts') ] # by default the access token has 5 mins of if access token is expired we use the refresh token to fetch new access token # The refresh token is valid for the next 24 hours. # When it finally expires too, the user will need to perform a full authentication again using their username and password
from django.urls import path, include from django.conf.urls import url from rest_framework.authtoken.views import ObtainAuthToken from rest_framework import routers from django.contrib.auth import views as auth_views from api.auth import views # Wire up our API using atomic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ path('login/', auth_views.LoginView.as_view(), name='login'), url(r'^get_token/', ObtainAuthToken.as_view()), path('register/', views.register, name='register'), path(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', views.activate, name='activate'), path('password_reset/', auth_views.PasswordResetView.as_view(form_class=views.HTMLPasswordResetForm), name='password_reset'), path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'), path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('reset/done/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), path('password_change/', auth_views.PasswordChangeView.as_view(), name='password_change'), path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(), name='password_change_done'), path('resend_activation/', views.resend_activation_email), path('user_data/', views.GetUserData.as_view()), path('user_links/', views.GetUserLinks.as_view()), path('get_user_groups/', views.GetUserGroups.as_view()) ] # TODO Proper git ignore
from django.urls import path from rest_framework.authtoken.views import ObtainAuthToken from . import views urlpatterns = [ path("api/auth/", ObtainAuthToken.as_view()), path("api/user/", views.UserView.as_view()), ]
from django.conf.urls import url, include from django.urls import path from rest_framework import routers from rest_framework.authtoken.views import ObtainAuthToken from backend.ExcelReading import views from backend.ExcelReading.views import * router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) urlpatterns = [ url(r'^', include(router.urls)), url(r'^api-auth/', include('rest_framework.urls', namespace="rest-framework")), url(r'connect/', ObtainAuthToken.as_view()), path(r'Schedule/', get_schedule, name="scheduleGot"), path(r'AllCourses/', all_courses, name="scheduleGot"), path(r'RecordCourse/', recordCourse, name="scheduleGot"), path(r'DeleteAllCourses/', DeleteAllCourse, name="scheduleGot"), path(r'GetScheduleFromDB/', getScheduleFromDB, name="scheduleGot"), path(r'GetAllUe/', getAllUe, name="scheduleGot"), path(r'OverlapCheck/', overLapCheck, name="scheduleGot"), path(r'gettingStudentsList/', gettingStudentList, name="scheduleGot"), path(r'associateCourseOnStudent/', associateCourseStudent, name="scheduleGot"), path(r'CountingCredit/', countingCredit, name="scheduleGot"), ]
from django.urls import path from .views import RegisterAPI from rest_framework.authtoken.views import ObtainAuthToken app_name = 'usuarios' urlpatterns = [ path('registrar', RegisterAPI.as_view(), name='register'), path('entrar', ObtainAuthToken.as_view(), name='login'), ]
from django.contrib import admin from rest_framework.authtoken.views import ObtainAuthToken from django.urls import path, include from emp_app.views import * urlpatterns = [ path('info/', EmpReg.as_view()), path('info/<str:id>/', EmpReg.as_view()), path('register/', EmpReg.as_view()), path('login/', EmpLogin.as_view()), path('get-token/', ObtainAuthToken.as_view()), ]
from django.urls import path, include from rest_framework import routers from rest_framework.authtoken.views import ObtainAuthToken from api_recipes.views import RecipeViewSet, UserViewSet router = routers.DefaultRouter() router.register('recipes', RecipeViewSet, basename='recipe') router.register('users', UserViewSet, basename='user') urlpatterns = [ path('', include(router.urls)), path('auth/', ObtainAuthToken.as_view(), name='auth') ]
from rest_framework.authtoken.views import ObtainAuthToken from django.conf.urls import url from src.core_auth import views urlpatterns = [ url(r'^login/$', ObtainAuthToken.as_view(), name='login'), url(r'^logout/$', views.UserLogoutView.as_view(), name='logout'), ]
from rest_framework.authtoken.models import Token from rest_framework.response import Response from rest_framework.authtoken.views import ObtainAuthToken from rest_framework.serializers import ValidationError class ObtainAuthToken(ObtainAuthToken): """ This class overriddes the default login, and doesn't allow employees with is_deleted=True to login with tokens """ def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] if user.employee.profile.is_deleted: raise ValidationError({ 'non_field_errors': [ 'Tu usuario ha sido eliminado, ponte en contacto con un administrador para restaurarlo.' ] }) token, created = Token.objects.get_or_create(user=user) return Response({'token': token.key}) obtain_auth_token = ObtainAuthToken.as_view()
"""restdemo URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include from restapp.views import PostViewSet from rest_framework.authtoken.views import ObtainAuthToken, obtain_auth_token from rest_framework.routers import SimpleRouter, DefaultRouter router = SimpleRouter() router.register('post', PostViewSet, basename='Post') urlpatterns = [ path('admin/', admin.site.urls), path('restapp/', include('restapp.urls')), path('', include(router.urls)), path('authtoken/', ObtainAuthToken.as_view()), ]
"""config URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include from gql.views import DRFGraphQLView from rest_framework.authtoken.views import ObtainAuthToken from apps import schema, route urlpatterns = [ path('admin/', admin.site.urls), path('auth-api/', ObtainAuthToken.as_view()), path('api/', include(route.urls)), path('gql/', DRFGraphQLView.as_view(graphiql=True, schema=schema.schema)), ]
from django.conf.urls import url from rest_framework.authtoken.views import ObtainAuthToken urlpatterns = [url(r'^token/', ObtainAuthToken.as_view(), name='token')]
# Authentication endpoints url(r'', include("django_cyverse_auth.urls", namespace="django_cyverse_auth")), # API Layer endpoints url(r'^api/', include("api.urls", namespace="api")), # v2 API auth by token url(r'^auth$', Authentication.as_view(), name='token-auth'), # DRF API Login/Logout url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), # Token login (Used internally by DRF?) url(r'^api-token-auth/', ObtainAuthToken.as_view()), # DB Admin Panel for admin users url(r'^admin/', include(admin.site.urls)) ] if settings.DEBUG and 'debug_toolbar.middleware.DebugToolbarMiddleware' in settings.MIDDLEWARE_CLASSES: try: import debug_toolbar urlpatterns += ( url(r'^__debug__/', include(debug_toolbar.urls)), ) except ImportError: pass
url(r"^new_company/(?P<pk>[0-9]+)$", new_company, name="new-company"), url(r"^update_company/(?P<pk>[0-9]+)$", update_company, name="update-company"), url(r"^agent/(?P<pk>[0-9]+)$", agent_detail, name="agent-detail"), url(r"^agentlist/(?P<pk>[0-9]+)$", agent_listing, name="agent-list"), url(r"^del_agent/(?P<pk>[0-9]+)$", delete_agent, name="del-agent"), url(r"^new_agent/(?P<pk>[0-9]+)$", new_agent, name="new-agent"), url(r"^update_agent/(?P<pk>[0-9]+)$", update_agent, name="update-agent"), url(r"^lender/(?P<pk>[0-9]+)$", lender_detail, name="lender-detail"), url(r"^lenderlist/(?P<pk>[0-9]+)$", lender_listing, name="lender-list"), url(r"^lenderlist2/(?P<pk>[0-9]+)$", lender_listing2, name="lender-list2"), url(r"^del_lender/(?P<pk>[0-9]+)$", delete_lender, name="del-lender"), url(r"^new_lender/(?P<pk>[0-9]+)$", new_lender, name="new-lender"), url(r"^update_lender/(?P<pk>[0-9]+)$", update_lender, name="update-lender"), url(r"^goal/(?P<pk>[0-9]+)$", GoalDetail.as_view(), name="goal-detail"), url(r"^goallist/(?P<pk>[0-9]+)$", goal_listing, name="goal-list"), url(r"^update_goal/(?P<pk>[0-9]+)$", update_goal, name="update-goal"), url(r"^new_goal/(?P<pk>[0-9]+)$", new_goal, name="new-goal"), url(r"^del_goal/(?P<pk>[0-9]+)$", delete_goal, name="del-goal"), url(r"^leadsources$", LeadSourceList.as_view(), name="leadsource-list"), url(r"^leadsource/(?P<pk>[0-9]+)$", LeadSourceDetail.as_view(), name="leadsource-detail"), url(r"^leadsourcelist/(?P<pk>[0-9]+)$", user_leadsources, name="leadsource-list"), url(r"^dashboard/(?P<pk>[0-9]+)$", dashboard, name="dashboard"), url(r"^leadschart/(?P<pk>[0-9]+)$", lead_chart, name="leads-chart"), url(r"^login/(?P<backend>[^/]+)/$", ObtainAuthToken.as_view()), url(r"^api-token/login/google/$", ObtainAuthToken.as_view()), ) # urlpatterns += patterns('', url(r'^api-token-auth/', 'rest_framework.authtoken.views.obtain_auth_token')) urlpatterns += patterns("", url(r"^api-token-auth/", NewAuthToken.as_view(), name="NewAuthToken")) urlpatterns = format_suffix_patterns(urlpatterns)
from django.urls import path from rest_framework.authtoken.views import ObtainAuthToken from .views import InSecureDataAPIView, AnotherInSecureDataAPIView urlpatterns = [ path('retrieve', InSecureDataAPIView.as_view()), path('retrieve_secure', AnotherInSecureDataAPIView.as_view()), path('get_token', ObtainAuthToken.as_view()) ]
"""drf URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.0/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls.conf import include from django.urls.conf import path from rest_framework.authtoken.views import ObtainAuthToken urlpatterns = [ path('admin/', admin.site.urls), path('api-token-auth/', ObtainAuthToken.as_view()), path('sample/', include('sample.urls', namespace='sample')), path('ep03/', include('ep03.urls', namespace='ep03')), path('ep04/', include('ep04.urls', namespace='ep04')), path('ep06/', include('ep06.urls', namespace='ep06')), path('api/', include('api.urls', namespace='api')), ]
1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from rest_framework.authtoken.views import ObtainAuthToken from music.views import ArtistAPIView, ArtistItemAPIView, AlbumAPIView, AlbumItemAPIView, TrackItemAPIView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api/auth/$$', ObtainAuthToken.as_view(), name='api_auth'), url(r'^api/artist/$', ArtistAPIView.as_view(), name='api_artist'), url(r'^api/artist/(?P<pk>\d+)/$', ArtistItemAPIView.as_view(), name='api_artist_item'), url(r'^api/album/$', AlbumAPIView.as_view(), name='api_album'), url(r'^api/artist/(?P<artist_id>\d+)/album/$', AlbumAPIView.as_view(), name='api_artist_item_album'), url(r'^api/album/(?P<pk>\d+)/$', AlbumItemAPIView.as_view(), name='api_album_item'), url(r'^api/track/(?P<pk>\d+)/$', TrackItemAPIView.as_view(), name='api_track_item'), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.conf.urls import url, include from rest_framework import routers from rest_framework.authtoken.views import ObtainAuthToken from . import views from django.conf import settings from django.conf.urls.static import static router = routers.DefaultRouter() router.register(r'posts', views.PostViewSet) router.register(r'usersbyusername', views.UserViewSetByUsername) router.register(r'profiles', views.ProfileViewSet) urlpatterns=[ url(r'^', include(router.urls)), url(r'^auth/',ObtainAuthToken.as_view()) ]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
from django.urls import path, include, re_path from user import views from rest_framework.authtoken.views import ObtainAuthToken urlpatterns = [ path('login/', ObtainAuthToken.as_view(), name='api_token_auth'), path('', include('rest_registration.api.urls', 'views.api_root')), path('users/', views.UserList.as_view(), name='user-list'), path('users/<int:pk>/', views.UserDetail.as_view(), name = 'user-detail'), path('profiles/', views.ProfileList.as_view(), name='profile-list'), path('profiles/<int:pk>', views.ProfileList.as_view(), name='profile-detail'), ]
from django.conf.urls import url, include from rest_framework import routers from loginapp import views from rest_framework.authtoken.views import ObtainAuthToken router = routers.DefaultRouter() # router.register(r'users', views.UserViewSet,basename='users') from loginapp.views import listapiview_all # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ url('', include(router.urls)), url('auth/', ObtainAuthToken.as_view()), url('users', listapiview_all.as_view()), ]
[admin page](/admin). Authors: [email protected]; ''', license=openapi.License(name="BSD License"), ), public=True, permission_classes=(permissions.AllowAny, ), ) urlpatterns = [ path('rosetta/', include('rosetta.urls')), path('preauth', preauth), path('export/', include('export.urls')), path("v1/api-token-auth/", ObtainAuthToken.as_view()), path( 'v1/api/', include([ path('announce/', include('announce.api.urls')), path('article/', include('article.api.urls')), path('account/', include('accounts.urls')), path('reader/', include('reader.api.urls')), path('bookmarks/', include('bookmarks.urls')), path('subscribe/', include('subscribe.urls')), path('', include('article.urls')) ])), path('api', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), path('doc/',
# from django.conf.urls import url, include from django.urls import include, path from rest_framework import routers from rest_framework.authtoken.views import ObtainAuthToken from . import views router = routers.DefaultRouter() router.register(r'user', views.UserViewSet, basename='user_view') router.register(r'create', views.UserRegisterView, basename='user_register') # router.register(r'training', views.UserStatsUpdateView, basename='user_training') urlpatterns = [ path(r'', include(router.urls)), path(r'auth/', ObtainAuthToken.as_view()), path(r'user/<int:id>/training/', views.UserStatsUpdateView.as_view(), name='train_view'), path(r'user/<int:id>/get-stats/', views.GetUserStatsView.as_view({'get': 'list'}), name='get_stats'), path(r'user/<int:id>/stats-price/', views.GetStatsPriceView.as_view({'get': 'list'}), name='get_prices'), path(r'user/<int:id>/add-exp/', views.UserExpUpdateView.as_view(), name='add_exp_view'), path(r'api-auth/', include('rest_framework.urls', namespace='rest_framework')), ]
from django.conf.urls import patterns, include, url from rest_framework.urlpatterns import format_suffix_patterns from rest_framework.authtoken.views import ObtainAuthToken from .views import UserAPIView, UserListAPIView, UserDetailAPIView urlpatterns = patterns('', url(r'^$', UserListAPIView.as_view()), url(r'^me$', UserAPIView.as_view(), name='user_view'), url(r'^(?P<user_id>[0-9]+)$', UserDetailAPIView.as_view()), url(r'^authenticate$', ObtainAuthToken.as_view()), )