[GH-ISSUE #622] Facing issues when using OAuth2 PKCE like shown in readme #404

Closed
opened 2026-03-03 16:48:25 +03:00 by kerem · 3 comments
Owner

Originally created by @flowinho on GitHub (Sep 3, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/622

Description:

Hey there!

The circumstances

I'd like to use the OAuthSwift framework with a custom system based on Amazon KeyCloak. However i'm facing issue upon initialization of the framework. The Readme describes the following method:

// create an instance and retain it
oauthswift = OAuth2Swift(
   ...
)
oauthswift.accessTokenBasicAuthentification = true

let codeVerifier = base64url("abcd...") // line with error
let codeChallenge = codeChallenge(for: codeVerifier) // line with error
 
let handle = oauthswift.authorize( // line with error
    withCallbackURL: "myApp://callback/",
    scope: "requestedScope", 
    state:"State01",
    codeChallenge: codeChallenge,
    codeChallengeMethod: "S256",
    codeVerifier: codeVerifier) { result in
    switch result {
        ...
     }
)

The problem

My compiler tells me that base64url, codeChallenge are unknown types and that oauthswift does not have a member authorize.

Any ideas on how to solve this? The app-project up until is very basic, no big changes have been made to the project-settings and third-party tools that edit the project (e.g. Cocoapods) are not present.

Looking forward to receiving your help. <3

Greetings from Southern Germany

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

  • Custom (but does not matter at this point)

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.5

  • 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

Originally created by @flowinho on GitHub (Sep 3, 2020). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/622 ### Description: Hey there! #### The circumstances I'd like to use the OAuthSwift framework with a custom system based on Amazon KeyCloak. However i'm facing issue upon initialization of the framework. The Readme describes the following method: ```swift // create an instance and retain it oauthswift = OAuth2Swift( ... ) oauthswift.accessTokenBasicAuthentification = true let codeVerifier = base64url("abcd...") // line with error let codeChallenge = codeChallenge(for: codeVerifier) // line with error let handle = oauthswift.authorize( // line with error withCallbackURL: "myApp://callback/", scope: "requestedScope", state:"State01", codeChallenge: codeChallenge, codeChallengeMethod: "S256", codeVerifier: codeVerifier) { result in switch result { ... } ) ``` #### The problem My compiler tells me that `base64url`, `codeChallenge` are unknown types and that `oauthswift` does not have a member `authorize`. Any ideas on how to solve this? The app-project up until is very basic, no big changes have been made to the project-settings and third-party tools that edit the project (e.g. Cocoapods) are not present. Looking forward to receiving your help. <3 Greetings from Southern Germany ### OAuth Provider? (Twitter, Github, ..): - Custom (but does not matter at this point) ### OAuth Version: - [ ] Version 1 - [X] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [ ] Swift Package Manager - [X] 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: - [X] 11.5 - [ ] 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
kerem closed this issue 2026-03-03 16:48:25 +03:00
Author
Owner

@kdembler commented on GitHub (Sep 23, 2020):

Seems both base64url and codeChallenge are stubs for your own implementation. This article https://auth0.com/docs/flows/call-your-api-using-the-authorization-code-flow-with-pkce has examples of generating both codeVerifier and codeChallenge in Swift

<!-- gh-comment-id:697415074 --> @kdembler commented on GitHub (Sep 23, 2020): Seems both `base64url` and `codeChallenge` are stubs for your own implementation. This article https://auth0.com/docs/flows/call-your-api-using-the-authorization-code-flow-with-pkce has examples of generating both `codeVerifier` and `codeChallenge` in Swift
Author
Owner

@lveecode commented on GitHub (Nov 23, 2020):

that oauthswift does not have a member authorize

OAuthSwift itself does not, but OAuth2Swift does. If it's an instance variable, make sure oauthswift is defined as OAuth2Swift (not OAuthSwift).
Alternatively, if it has to be a generic OAuthSwift,

let oauthswift = OAuth2Swift( [...] )

self.oauthswift = oauthswift

let handle = oauthswift.authorize( [...] ) // no error anymore
<!-- gh-comment-id:732241966 --> @lveecode commented on GitHub (Nov 23, 2020): > that oauthswift does not have a member `authorize` OAuthSwift itself does not, but OAuth2Swift does. If it's an instance variable, make sure oauthswift is defined as OAuth2Swift (not OAuthSwift). Alternatively, if it has to be a generic OAuthSwift, ``` let oauthswift = OAuth2Swift( [...] ) self.oauthswift = oauthswift let handle = oauthswift.authorize( [...] ) // no error anymore ```
Author
Owner

@MrWoWander commented on GitHub (Mar 2, 2021):

I wrote and sent to the PR #647 generator random code verifier and code challenge

<!-- gh-comment-id:788655185 --> @MrWoWander commented on GitHub (Mar 2, 2021): I wrote and sent to the PR #647 generator random code verifier and code challenge
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#404
No description provided.