mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[PR #691] [MERGED] Custom Server Behavior - Requests & Responses customisation #719
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#719
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/691
Author: @juliengdt
Created: 1/27/2022
Status: ✅ Merged
Merged: 1/28/2022
Merged by: @phimage
Base:
master← Head:develop📝 Commits (3)
f8462b3Customize request headers and custom path responsebd3166fAdd Withings OAuth2 for testing6f78efdMerge branch 'feature/Dynamic-Keypath' into develop📊 Changes
5 files changed (+117 additions, -21 deletions)
View changed files
📝
Demo/Common/Services.plist(+7 -0)📝
Demo/Common/ViewController.swift(+43 -0)📝
OAuthSwift.xcodeproj/project.pbxproj(+11 -9)📝
Sources/OAuth2Swift.swift(+29 -8)📝
Sources/OAuthSwiftClient.swift(+27 -4)📄 Description
What for ?
As I use OAuthSwift in some projects, I discover that certain OAuth provider may be not aware about being 100% Oauth2 compliant. For example, Withings new OAuth2 provider added some custom behavior, which are breaking changes:
Source: Deprecating access and refresh tokens endpoints (Withings support)
Custom get/refresh-token request parameters
Developer have to inject a custom parameter to tell what you want to do.
For a get/refresh-token request, the parameter is:
Custom get/refresh-token response
The get/refresh-token response is now a bit different: datas are encapsulated in an object
before
after
How
The goal of this PR is to add the ability to inject some datas, without touching existing behavior.
Custom get/refresh-token request parameters
OAuth2Swift init now support a new parameter, called
customAccessTokenParams, which is nil by default.This parameter will be injected in the oauth client and, if exists, will add this dictionary in the parameter dictionary for get/refresh URL request
example:
the parameter is optional, so existing code will work as expected:
Custom get/refresh-token response
OAuth2Swift init now support a new parameter, called
customKeypath, which is nil by default.This parameter will be used in the oauth client and, if exists, will modify the path where to get data (ie token, expiration.. so on) in the JSON response.
example:
the parameter is optional, so existing code will work as expected:
Bonus
In-project test app has been modified to play with tithings oauth2 too, only oauth was playable.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.