[GH-ISSUE #284] Headers get overwritten with nil #168

Closed
opened 2026-03-03 16:46:19 +03:00 by kerem · 4 comments
Owner

Originally created by @jwrigh26 on GitHub (Oct 5, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/284

  1. Init an OAuth2Swift object
  2. Set parameters for OAuth2Swift object
  3. Call authorizeWithCallbackURL(_:scope:state:params:headers:success:failure)
  4. Getting error back with status code: 403

This is caused because on line 203 of OAuth2Swift.swift:
var headers: [String:String]? = nil

The headers passed in the from the method get overwritten by the local variable headers and therefore are never used. By changing the code to

var headers: [String:String]? = headers

I was successful with getting OAuth to happen.

  • OS targeted iOS: 9.3.5
  • OAuth provider: MapMyRun
  • OAuthSwift version: master
Originally created by @jwrigh26 on GitHub (Oct 5, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/284 1. Init an OAuth2Swift object 2. Set parameters for OAuth2Swift object 3. Call authorizeWithCallbackURL(_:scope:state:params:headers:success:failure) 4. Getting error back with status code: 403 This is caused because on line **203** of OAuth2Swift.swift: `var headers: [String:String]? = nil` The headers passed in the from the method get overwritten by the local variable _headers_ and therefore are never used. By changing the code to `var headers: [String:String]? = headers` I was successful with getting OAuth to happen. - **OS targeted iOS: 9.3.5** - **OAuth provider: MapMyRun** - **OAuthSwift version: master**
kerem 2026-03-03 16:46:19 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@phimage commented on GitHub (Oct 5, 2016):

"var headers: [String:String]? = nil" is an old code
version 0.6 introduce the headers in function parameters
will be fixed

<!-- gh-comment-id:251721215 --> @phimage commented on GitHub (Oct 5, 2016): "var headers: [String:String]? = nil" is an old code version 0.6 introduce the headers in function parameters will be fixed
Author
Owner

@jwrigh26 commented on GitHub (Oct 5, 2016):

I see. Yes my bad I thought our team was using master but it turns out we are still on the swift3.0 branch. Do you know when this will be fixed for Swift3.0?

<!-- gh-comment-id:251737286 --> @jwrigh26 commented on GitHub (Oct 5, 2016): I see. Yes my bad I thought our team was using **master** but it turns out we are still on the **swift3.0** branch. Do you know when this will be fixed for Swift3.0?
Author
Owner

@phimage commented on GitHub (Oct 5, 2016):

I have a probleme with my code now, I can compil due to segmentation fault 11 (and weird error dataTask ambigous, JSOnSErialisation.data not exist..)

The solution I want to commit when I can
var finalHeaders: [String:String]? = headers
then finalHeaders += instead of headers =
then use finalHeads in request function

<!-- gh-comment-id:251738767 --> @phimage commented on GitHub (Oct 5, 2016): I have a probleme with my code now, I can compil due to segmentation fault 11 (and weird error dataTask ambigous, JSOnSErialisation.data not exist..) The solution I want to commit when I can var finalHeaders: [String:String]? = headers then finalHeaders += instead of headers = then use finalHeads in request function
Author
Owner

@jwrigh26 commented on GitHub (Oct 5, 2016):

Awesome! Looking forward to the solution. Thank you for the fast response. Sending positive energy your way on resolving the wonderful Xcode compile issues.

<!-- gh-comment-id:251739604 --> @jwrigh26 commented on GitHub (Oct 5, 2016): Awesome! Looking forward to the solution. Thank you for the fast response. Sending positive energy your way on resolving the wonderful Xcode compile issues.
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#168
No description provided.