Merge pull request #4 from martymcguire/master
Updates for micropub.rocks auth support
This commit is contained in:
commit
794d95c624
|
@ -135,6 +135,7 @@ class MicropubClient:
|
||||||
'me': me,
|
'me': me,
|
||||||
'client_id': self.client_id,
|
'client_id': self.client_id,
|
||||||
'redirect_uri': redirect_url,
|
'redirect_uri': redirect_url,
|
||||||
|
'response_type': 'code',
|
||||||
'state': '{}|{}'.format(csrf_token, state or ''),
|
'state': '{}|{}'.format(csrf_token, state or ''),
|
||||||
}
|
}
|
||||||
if scope:
|
if scope:
|
||||||
|
@ -205,6 +206,9 @@ class MicropubClient:
|
||||||
'Flask-Micropub: auth response: %d - %s', response.status_code,
|
'Flask-Micropub: auth response: %d - %s', response.status_code,
|
||||||
response.text)
|
response.text)
|
||||||
|
|
||||||
|
try:
|
||||||
|
rdata = dict((k,[v]) for (k,v) in response.json().items())
|
||||||
|
except ValueError:
|
||||||
rdata = parse_qs(response.text)
|
rdata = parse_qs(response.text)
|
||||||
if response.status_code < 200 or response.status_code >= 300:
|
if response.status_code < 200 or response.status_code >= 300:
|
||||||
error_vals = rdata.get('error')
|
error_vals = rdata.get('error')
|
||||||
|
@ -258,6 +262,7 @@ class MicropubClient:
|
||||||
'redirect_uri': redirect_uri,
|
'redirect_uri': redirect_uri,
|
||||||
'client_id': self.client_id,
|
'client_id': self.client_id,
|
||||||
'state': wrapped_state,
|
'state': wrapped_state,
|
||||||
|
'grant_type': 'authorization_code',
|
||||||
}
|
}
|
||||||
flask.current_app.logger.debug(
|
flask.current_app.logger.debug(
|
||||||
'Flask-Micropub: requesting access token from: %s, data: %s',
|
'Flask-Micropub: requesting access token from: %s, data: %s',
|
||||||
|
@ -274,6 +279,9 @@ class MicropubClient:
|
||||||
error='bad response from token endpoint: {}'
|
error='bad response from token endpoint: {}'
|
||||||
.format(token_response))
|
.format(token_response))
|
||||||
|
|
||||||
|
try:
|
||||||
|
tdata = dict((k,[v]) for (k,v) in token_response.json().items())
|
||||||
|
except ValueError:
|
||||||
tdata = parse_qs(token_response.text)
|
tdata = parse_qs(token_response.text)
|
||||||
if 'access_token' not in tdata:
|
if 'access_token' not in tdata:
|
||||||
return AuthResponse(
|
return AuthResponse(
|
||||||
|
|
Loading…
Reference in New Issue