hadapi: Expose authentication URI

This commit is contained in:
Stuart Longland 2018-01-06 17:32:16 +10:00
parent 5265def117
commit 4ae4aa701d
Signed by: stuartl
GPG Key ID: 6AA32EFB18079BAA

View File

@ -40,7 +40,9 @@ class HackadayAPI(object):
"""
HAD_API_URI='https://api.hackaday.io/v1'
HAD_AUTH_URI='https://hackaday.io/authorize'
HAD_AUTH_URI='https://hackaday.io/authorize'\
'?client_id=%(CLIENT_ID)s'\
'&response_type=code'
HAD_TOKEN_URI='https://auth.hackaday.io/access_token'\
'?client_id=%(CLIENT_ID)s'\
'&client_secret=%(CLIENT_SECRET)s'\
@ -164,6 +166,14 @@ class HackadayAPI(object):
# oAuth endpoints
@property
def auth_uri(self):
"""
Return the auth URI that we need to send the user to if they're not
logged in.
"""
return self._auth_uri % dict(CLIENT_ID=self._client_id)
def get_token(self, code):
"""
Fetch the token for API queries from the authorization code given.