From cd6016143db1449133eb5c97073208b889ed97b5 Mon Sep 17 00:00:00 2001 From: chittal Date: Wed, 25 Aug 2021 23:21:05 +0530 Subject: [PATCH] Update github.py for fastapi client --- loginpass/github.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/loginpass/github.py b/loginpass/github.py index 794d624..6e1cb28 100644 --- a/loginpass/github.py +++ b/loginpass/github.py @@ -26,8 +26,8 @@ class GitHub(object): 'userinfo_endpoint': 'https://api.github.com/user', } - def userinfo(self, **kwargs): - resp = self.get(self.OAUTH_CONFIG['userinfo_endpoint'], **kwargs) + async def userinfo(self, **kwargs): + resp = await self.get(self.OAUTH_CONFIG['userinfo_endpoint'], **kwargs) data = resp.json() params = { @@ -45,9 +45,11 @@ def userinfo(self, **kwargs): # If that is the case we get all the users emails regardless if private or note # and use the one he/she has marked as `primary` if params.get('email') is None: - resp = self.get('user/emails', **kwargs) + resp = await self.get('user/emails', **kwargs) resp.raise_for_status() data = resp.json() - params["email"] = next(email['email'] for email in data if email['primary']) + params["email"], params["email_verified"] = next( + (email["email"], email["verified"]) for email in data if email["primary"] + ) return UserInfo(params)