Fix parsing Withings new response format Fix OAuthSwift/OAuthSwift#663 #675
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As stated in #663, the new Withings endpoint:
action
, with value "requesttoken";grant_type
to equal "refresh_token" (not "authorization_code");body
andstatus
, with the former keys, includingcode
, all in an object down belowbody
.Description code change:
This PR addresses nr.3, because nr.1 and 2 don't need code modifications (see below).
The provided solution extracts the response parameters if the response dictionary contains a key
body
. To my knowledge, only Withings uses this particular response format.Requirement nr.1:
To mitigate requirement nr.1, the user can append the
accessTokenUrl
with?action=requesttoken
, i.e.:This is more of a workaround, but it works. As such, no modifications are needed in the source code. An alternative would be to introduce a boolean, specifically to accommodate Withings. My preference is to omit such special cases as much as possible. But please give feedback if this workaround is not preferred.
Requirement nr.2:
Requirement nr.2 is already implemented, and doesn't need any changes:
OAuthSwift/Sources/OAuthSwiftClient.swift
Line 201 in d85964b
I have tested it, and with these changes, I can successfully authorize with Withings and can also refresh the token.