[GH-ISSUE #110] Foursquare authentication failing #67

Closed
opened 2026-03-03 16:45:22 +03:00 by kerem · 3 comments
Owner

Originally created by @nmorenor on GitHub (Sep 23, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/110

Hi, I'm using OAuthSwift library on a project, and while doing Foursquare authentication I found something interesting inside the file OAuth2Swift.swift, when calling authorizeWithCallbackURL function I see that the returned url has both a query string and a fragment, it will be something like.

https://somehost/somepath?access_token=${atoken}#=

and because of that the responseParameters lose the access_token value with the code:

            var responseParameters: Dictionary<String, String> = Dictionary()
            if let query = url.query {
                responseParameters = query.parametersFromQueryString()
            }
            if ((url.fragment) != nil && url.fragment!.isEmpty == false) {
                responseParameters = url.fragment!.parametersFromQueryString()
            }

Cheers
Ignacio

Originally created by @nmorenor on GitHub (Sep 23, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/110 Hi, I'm using OAuthSwift library on a project, and while doing Foursquare authentication I found something interesting inside the file OAuth2Swift.swift, when calling authorizeWithCallbackURL function I see that the returned url has both a query string and a fragment, it will be something like. https://somehost/somepath?access_token=${atoken}#_=_ and because of that the responseParameters lose the access_token value with the code: ``` var responseParameters: Dictionary<String, String> = Dictionary() if let query = url.query { responseParameters = query.parametersFromQueryString() } if ((url.fragment) != nil && url.fragment!.isEmpty == false) { responseParameters = url.fragment!.parametersFromQueryString() } ``` Cheers Ignacio
kerem closed this issue 2026-03-03 16:45:22 +03:00
Author
Owner

@phimage commented on GitHub (Sep 24, 2015):

There is a difference between Oauth1 and Oauth2 here
Oauth1 does'nt have this problem because there is an else between query and fragment

This is a solution to fix OAuth2, just add the else to choose only query if there is query and fragment

but we can also merge ? I make a PR for that : PR #111
PR can be closed if first solution is choosen

<!-- gh-comment-id:142916324 --> @phimage commented on GitHub (Sep 24, 2015): There is a difference between Oauth1 and Oauth2 here Oauth1 does'nt have this problem because there is an `else` between query and fragment This is a solution to fix OAuth2, just add the `else` to choose only `query` if there is query and fragment but we can also merge ? I make a PR for that : PR #111 PR can be closed if first solution is choosen
Author
Owner

@nmorenor commented on GitHub (Sep 24, 2015):

Is that the right thing to do?, or perhaps it could be better to concatenate both dictionaries :)

<!-- gh-comment-id:142940916 --> @nmorenor commented on GitHub (Sep 24, 2015): Is that the right thing to do?, or perhaps it could be better to concatenate both dictionaries :)
Author
Owner

@phimage commented on GitHub (Sep 24, 2015):

merge = concatenate, my second solution in my pull request
dongri will choose the right one if he has time ;)

<!-- gh-comment-id:142942782 --> @phimage commented on GitHub (Sep 24, 2015): merge = concatenate, my second solution in my pull request dongri will choose the right one if he has time ;)
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#67
No description provided.