Commit f298c42a authored by Jens Langhammer's avatar Jens Langhammer

Add OpenID API

parent d0a7bf5e
......@@ -2,6 +2,7 @@
from django.apps import AppConfig
class PassbookAPIConfig(AppConfig):
"""passbook API Config"""
......
"""passbook api urls"""
from django.urls import include, path
urlpatterns = []
from passbook.api.v1.urls import urlpatterns as v1_urls
urlpatterns = [
path('v1/', include(v1_urls))
]
"""Passbook v1 OpenID API"""
from django.http import JsonResponse
from django.views import View
from oauth2_provider.views.mixins import ScopedResourceMixin
class OpenIDUserInfoView(ScopedResourceMixin, View):
"""Passbook v1 OpenID API"""
required_scopes = ['openid:userinfo']
def get(self, request, *args, **kwargs):
"""Passbook v1 OpenID API"""
payload = {
'sub': request.user.pk,
'name': request.user.get_full_name(),
'given_name': request.user.first_name,
'family_name': request.user.last_name,
'preferred_username': request.user.username
}
return JsonResponse(payload)
"""Passbook API URLs"""
from django.urls import path
from passbook.api.v1.openid import OpenIDUserInfoView
urlpatterns = [
path('openid/', OpenIDUserInfoView.as_view(), name='openid')
]
from rest_framework.viewsets import ViewSet
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment