Skip to content

Commit

Permalink
Fix instagram profile method.
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed May 21, 2019
1 parent f832272 commit 9fa385a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions loginpass/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ class Instagram(OAuthBackend):
}

def profile(self, token=None, **kwargs):
payload = {'access_token': token['access_token']}
resp = self.get('/v1/users/self', params=payload, **kwargs)
resp.raise_for_status()
return UserInfo(map_profile_fields(resp.json()['data'], {
data = None
if token is not None:
data = token.get('user')

if data is None:
resp = self.get('/v1/users/self', **kwargs)
resp.raise_for_status()
data = resp.json()['data']
return UserInfo(map_profile_fields(data, {
'sub': lambda o: str(o['id']),
'name': 'name',
'given_name': 'full_name',
Expand Down

0 comments on commit 9fa385a

Please sign in to comment.