mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[PR #219] [CLOSED] Autorenew OAuth2 access tokens #575
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#575
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/219
Author: @FGoessler
Created: 4/5/2016
Status: ❌ Closed
Base:
master← Head:#217-Autorenew-OAuth2-Tokens📝 Commits (10+)
da78f59#217 autorenew Oauth2 access tokens: created an extension on NSError to detect whether it was caused by an invalid access tokenffe3a94#217 autorenew OAuth2 access tokens on every request via an OAuthSwiftClient6142484#217 autorenew OAuth2 access tokens: created new callback property on OAuthSwiftClient to get informed about access token renewalsa773fd1#217 autorenew OAuth2 access tokens: token expiration detection for Facebooks APId286157#217 autorenew OAuth2 access tokens: added unit test for autorenewal04593d2#217 autorenew OAuth2 access tokens: added documentation commentsef1288c#217 autorenew OAuth2 access tokens: refactored tokenExpirationHandler which now has an assert to not use it for OAuth12db41a4added the possibility to cancel requests which haven't been started yet63154b2Refactoring to make the implementation of new features easier.83df2d7Implemented a cancel method on OAuthSwiftTokenRefreshingRequest📊 Changes
16 files changed (+981 additions, -500 deletions)
View changed files
📝
OAuthSwift.xcodeproj/project.pbxproj(+38 -0)➕
OAuthSwift/NSError+OAuthSwift.swift(+56 -0)📝
OAuthSwift/OAuth1Swift.swift(+9 -7)📝
OAuthSwift/OAuth2Swift.swift(+19 -23)📝
OAuthSwift/OAuthSwift.swift(+7 -2)📝
OAuthSwift/OAuthSwiftClient.swift(+73 -189)📝
OAuthSwift/OAuthSwiftHTTPRequest.swift(+163 -147)➕
OAuthSwift/OAuthSwiftHTTPRequestConfig.swift(+123 -0)📝
OAuthSwift/OAuthSwiftMultipartData.swift(+1 -1)➕
OAuthSwift/OAuthSwiftTokenRefreshingRequest.swift(+99 -0)➕
OAuthSwiftTests/NSErrorOAuthSwiftTest.swift(+63 -0)📝
OAuthSwiftTests/OAuth2SwiftTests.swift(+8 -25)📝
OAuthSwiftTests/OAuthSwiftClientTests.swift(+71 -69)➕
OAuthSwiftTests/OAuthSwiftHTTPRequestConfigTest.swift(+208 -0)📝
OAuthSwiftTests/OAuthSwiftRequestTests.swift(+35 -34)📝
OAuthSwiftTests/TestServer.swift(+8 -3)📄 Description
This PR aims to make the access token renewal process transparent to clients of this library as discussed in #217.
The implementation differs from my proposed solution in the issue since the token renewal process is to tightly coupled with the
OAuth2Swiftclass.Now the
OAuthSwiftClientexposes a callback property which can be set to handle expired/invalid tokens and will retry the request via the completion block.OAuth2Swiftconfigures this property such that it requests a new access tokens with its refresh token and stores the new token.In case a request failed the error response is checked if the cause is an invalid/expired token. Therefore I created an extension on NSError which I based on the code and specification in the Wiki. It also handles special cases for Facebook.
I would appreciate feedback about the convenience method
startAuthorizedRequest(...)inOAuth2Swiftwhich was introduced by @fabiomassimo. Since there was no release since this method was added it should be save to remove it, but for now I left it in and marked it as deprecated.This PR also includes the changes to the unit tests done in #218 since I rebased this branch onto the other. I can perform a rebase on master as soon as the other PR is merged to make the merge and history nicer.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.