Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuthSwiftClient/requestWithAutomaticAccessTokenRenewal with YouTube Data API (v3) #677

Open
15 tasks
appsird opened this issue Sep 23, 2021 · 0 comments
Open
15 tasks

Comments

@appsird
Copy link

appsird commented Sep 23, 2021

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant