[GH-ISSUE #472] responseType is set but not used #309

Closed
opened 2026-03-03 16:47:34 +03:00 by kerem · 1 comment
Owner

Originally created by @yakovmanshin on GitHub (Jun 21, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/472

Description:

responseType that’s set during OAuth2Swift initialization is not used.

The OAuth provider I’m using returns token as id_token. Here I set the token during initialization of OAuth2Swift:
let oauth = OAuth2Swift(consumerKey: "xxxx-xxxx-xxxx-xxxx", consumerSecret: "", authorizeUrl: "https://example.com/oauth2/authorize", accessTokenUrl: "https://example.com/oauth2/token", responseType: "id_token")

OAuthSwift doesn’t recognize the token, although it can be successfully extracted using Postman or similar software.

The problem was found near line 95 in OAuth2Swift.swift:
if let accessToken = responseParameters["access_token"]

Instead of using responseType as dictionary key, the statement always uses access_token for extracting the token.

The correct code would be:
if let accessToken = responseParameters[this.responseType]

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

Private OAuth provider

OAuth Version:

Version 2

OS (Please fill the version) :

iOS 11.4

Installation method:

CocoaPods

Library version:

v1.2.0 (Swift 4.0)

Xcode version:

9.4.1 (Swift 4.1)

Originally created by @yakovmanshin on GitHub (Jun 21, 2018). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/472 ### Description: responseType that’s set during `OAuth2Swift` initialization is not used. The OAuth provider I’m using returns token as `id_token`. Here I set the token during initialization of `OAuth2Swift`: `let oauth = OAuth2Swift(consumerKey: "xxxx-xxxx-xxxx-xxxx", consumerSecret: "", authorizeUrl: "https://example.com/oauth2/authorize", accessTokenUrl: "https://example.com/oauth2/token", responseType: "id_token")` **OAuthSwift doesn’t recognize the token, although it can be successfully extracted using Postman or similar software.** The problem was found near line 95 in [OAuth2Swift.swift](https://github.com/OAuthSwift/OAuthSwift/blob/master/Sources/OAuth2Swift.swift): `if let accessToken = responseParameters["access_token"]` **Instead of using `responseType` as dictionary key, the statement always uses `access_token` for extracting the token.** The correct code would be: `if let accessToken = responseParameters[this.responseType]` ### OAuth Provider? (Twitter, Github, ..): Private OAuth provider ### OAuth Version: Version 2 ### OS (Please fill the version) : iOS 11.4 ### Installation method: CocoaPods ### Library version: v1.2.0 (Swift 4.0) ### Xcode version: 9.4.1 (Swift 4.1)
kerem closed this issue 2026-03-03 16:47:35 +03:00
Author
Owner

@yakovmanshin commented on GitHub (Jun 21, 2018):

The issue is no longer relevant.

<!-- gh-comment-id:399244342 --> @yakovmanshin commented on GitHub (Jun 21, 2018): The issue is no longer relevant.
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#309
No description provided.