mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 04:35:56 +03:00
[PR #675] Fix parsing Withings new response format Fix OAuthSwift/OAuthSwift#663 #716
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#716
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/OAuthSwift/OAuthSwift/pull/675
Author: @BJAdeGraaf
Created: 8/30/2021
Status: 🔄 Open
Base:
master← Head:fix/withings-endpoint📝 Commits (1)
75e32f4Fix parsing Withings new response format Fix OAuthSwift/OAuthSwift#663📊 Changes
1 file changed (+5 additions, -1 deletions)
View changed files
📝
Sources/OAuthSwiftClient.swift(+5 -1)📄 Description
As stated in #663, the new Withings endpoint:
action, with value "requesttoken";grant_typeto equal "refresh_token" (not "authorization_code");bodyandstatus, 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
accessTokenUrlwith?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:
github.com/OAuthSwift/OAuthSwift@d85964b96d/Sources/OAuthSwiftClient.swift (L201)I have tested it, and with these changes, I can successfully authorize with Withings and can also refresh the token.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.