[GH-ISSUE #667] Cannot change URLRequest's timeoutInterval #434

Open
opened 2026-03-03 16:48:40 +03:00 by kerem · 1 comment
Owner

Originally created by @MikeSpelling on GitHub (Jul 5, 2021).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/667

Description:

Using OAuth2Swift startAuthorizedRequest there is no way to override the requestTimeout. Although we can override the sessions timeout via:

let configuration = oauthswift.client.sessionFactory.configuration
configuration.timeoutIntervalForRequest = 300
oauth.client.sessionFactory.configuration = configuration

This will be overridden by the actual URLRequest's timeoutInterval used as, from Apple, https://developer.apple.com/documentation/foundation/urlsessionconfiguration:

In some cases, the policies defined in this configuration may be overridden by policies specified by an NSURLRequest object provided for a task. Any policy specified on the request object is respected unless the session’s policy is more restrictive.

In this case the OAuthSwiftHTTPRequest instantiates it's Config object which has a default timeoutInterval set to 60.
Changing the URLSession's configuration's timeoutIntervalForRequest does not seem to be able to override this.

OAuth Provider? (Twitter, Github, ..):

Custom - using our own Identity Server

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually

Library version:

  • head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • other: (v2.2.0)

Xcode version:

  • 11.4 (Swift 5.2)
  • 11.x (Swift 5.1)
  • 10.x (Swift 5.0)
  • other: (Xcode 12.5.1, Swift 5.4)
  • objective c
Originally created by @MikeSpelling on GitHub (Jul 5, 2021). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/667 ### Description: Using OAuth2Swift startAuthorizedRequest there is no way to override the requestTimeout. Although we can override the sessions timeout via: ``` let configuration = oauthswift.client.sessionFactory.configuration configuration.timeoutIntervalForRequest = 300 oauth.client.sessionFactory.configuration = configuration ``` This will be overridden by the actual URLRequest's timeoutInterval used as, from Apple, https://developer.apple.com/documentation/foundation/urlsessionconfiguration: > In some cases, the policies defined in this configuration may be overridden by policies specified by an NSURLRequest object provided for a task. Any policy specified on the request object is respected unless the session’s policy is more restrictive. In this case the `OAuthSwiftHTTPRequest` instantiates it's `Config` object which has a default timeoutInterval set to 60. Changing the URLSession's configuration's timeoutIntervalForRequest does not seem to be able to override this. ### OAuth Provider? (Twitter, Github, ..): Custom - using our own Identity Server ### OAuth Version: - [ ] Version 1 - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Swift Package Manager - [ ] Manually ### Library version: - [ ] head - [ ] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [x] other: (v2.2.0) ### Xcode version: - [ ] 11.4 (Swift 5.2) - [ ] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [x] other: (Xcode 12.5.1, Swift 5.4) - [ ] objective c
Author
Owner

@MikeSpelling commented on GitHub (Aug 12, 2021):

Any update on this? I couldn't find a solution so I've created a PR at OAuthSwift/pull/672 which solves it for me...

<!-- gh-comment-id:897784603 --> @MikeSpelling commented on GitHub (Aug 12, 2021): Any update on this? I couldn't find a solution so I've created a PR at OAuthSwift/pull/672 which solves it for me...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#434
No description provided.