[GH-ISSUE #677] OAuthSwiftClient/requestWithAutomaticAccessTokenRenewal with YouTube Data API (v3) #437

Open
opened 2026-03-03 16:48:41 +03:00 by kerem · 0 comments
Owner

Originally created by @appsird on GitHub (Sep 23, 2021).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/677

Description:

OAuth Provider? :

YouTube Data API (v3)

OAuth Version:

  • Version 1
  • [ x] Version 2

OS (Please fill the version) :

  • iOS :
  • [ x] OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • [ x] Swift Package Manager
  • Manually

Library version:

  • [ x] head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • other: (Please fill in the version you are using.)

Xcode version:

  • 11.4 (Swift 5.2)

  • 11.x (Swift 5.1)

  • 10.x (Swift 5.0)

  • [ x] other: (Swift 5.5, Xcode 13)

  • objective c

The function OAuthSwiftClient/requestWithAutomaticAccessTokenRenewal sends a request, and if the access token has timed out (typically 60 minutes or so) - obtains a new access token and then retries the originally passed request. This works exactly in this manner. However, for the Google YouTube Data API (v3) the access token is sent in the Header of each request. Hence, the retry of a request should use the newly acquired access token in the header. Currently, it re-uses the old access token.

I am uncertain if this is relevant to other Oauth2 API access, and did not check in the appropriate change. In OAuthSwiftClient/requestWithAutomaticAccessTokenRenewal (near line 302) I added the following line to create the updated header containing the refreshed access token for the retry. This then works as needed for the Google YouTube Data API (v3).

Would appreciate if this could be integrated without affecting other API's. Assistance welcome.

onTokenRenewal(.success(credential))                        
let headers: OAuthSwift.Headers = [
    "Authorization": "Bearer " + credential.oauthToken
]
Originally created by @appsird on GitHub (Sep 23, 2021). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/677 ### Description: ### OAuth Provider? : YouTube Data API (v3) ### OAuth Version: - [ ] Version 1 - [ x] Version 2 ### OS (Please fill the version) : - [ ] iOS : - [ x] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [ x] Swift Package Manager - [ ] Manually ### Library version: - [ x] head - [ ] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [ ] 11.4 (Swift 5.2) - [ ] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [ x] other: (Swift 5.5, Xcode 13) - [ ] objective c The function OAuthSwiftClient/requestWithAutomaticAccessTokenRenewal sends a request, and if the access token has timed out (typically 60 minutes or so) - obtains a new access token and then retries the originally passed request. This works exactly in this manner. However, for the Google YouTube Data API (v3) the access token is sent in the Header of each request. Hence, the retry of a request should use the newly acquired access token in the header. Currently, it re-uses the old access token. I am uncertain if this is relevant to other Oauth2 API access, and did not check in the appropriate change. In OAuthSwiftClient/requestWithAutomaticAccessTokenRenewal (near line 302) I added the following line to create the updated header containing the refreshed access token for the retry. This then works as needed for the Google YouTube Data API (v3). Would appreciate if this could be integrated without affecting other API's. Assistance welcome. ``` onTokenRenewal(.success(credential)) let headers: OAuthSwift.Headers = [ "Authorization": "Bearer " + credential.oauthToken ] ```
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#437
No description provided.