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

OAuthSwiftHTTPRequest old headers overriding new headers #640

Open
8 of 21 tasks
mariuskurgonas opened this issue Dec 28, 2020 · 0 comments
Open
8 of 21 tasks

OAuthSwiftHTTPRequest old headers overriding new headers #640

mariuskurgonas opened this issue Dec 28, 2020 · 0 comments

Comments

@mariuskurgonas
Copy link

Description:

OAuthSwiftHTTPRequest.swift line 423:

self.urlRequest.allHTTPHeaderFields = requestHeaders + headers

Here requestHeaders are potentially new headers set after the access token was refreshed and headers are old headers.

Problems comes when both variables contain the same key and different value. When merging with a + operator in swift - it takes the last elements values.

So after token refresh if there was a new access token header set on requestHeaders and headers contained old value,
in the end the final headers would contain the old value.

THE FIX:

Reverse the order or variables being merged like:

self.urlRequest.allHTTPHeaderFields = headers + requestHeaders

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

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: (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)

  • other: (Please fill in the version you are using.)

  • objective c

  • swift

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