2018-11-24 21:24:11 +00:00
|
|
|
"""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"""
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
required_scopes = ["openid:userinfo"]
|
2018-11-24 21:24:11 +00:00
|
|
|
|
2019-12-31 11:45:29 +00:00
|
|
|
def get(self, request, *_, **__):
|
2018-11-24 21:24:11 +00:00
|
|
|
"""Passbook v1 OpenID API"""
|
|
|
|
payload = {
|
2019-12-31 11:51:16 +00:00
|
|
|
"sub": request.user.uuid.int,
|
|
|
|
"name": request.user.get_full_name(),
|
|
|
|
"given_name": request.user.name,
|
|
|
|
"family_name": "",
|
|
|
|
"preferred_username": request.user.username,
|
|
|
|
"email": request.user.email,
|
2018-11-24 21:24:11 +00:00
|
|
|
}
|
|
|
|
return JsonResponse(payload)
|