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"""
|
|
|
|
|
|
|
|
required_scopes = ['openid:userinfo']
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
"""Passbook v1 OpenID API"""
|
|
|
|
payload = {
|
2018-12-09 20:05:25 +00:00
|
|
|
'sub': request.user.uuid.int,
|
2018-11-24 21:24:11 +00:00
|
|
|
'name': request.user.get_full_name(),
|
|
|
|
'given_name': request.user.first_name,
|
|
|
|
'family_name': request.user.last_name,
|
2018-11-25 11:31:21 +00:00
|
|
|
'preferred_username': request.user.username,
|
|
|
|
'email': request.user.email,
|
2018-11-24 21:24:11 +00:00
|
|
|
}
|
|
|
|
return JsonResponse(payload)
|