[GH-ISSUE #328] Trying to authenticate GitHub API but success or failure doesn't run #202

Closed
opened 2026-03-03 16:46:38 +03:00 by kerem · 5 comments
Owner

Originally created by @dannymout on GitHub (Dec 30, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/328

Description:

This is the code I'm using:

        oauthswift = OAuth2Swift(consumerKey: "XXXXXXXXXXXXXXXXXXX", consumerSecret: "XXXXXXXXXXXXXXXXXXX", authorizeUrl: "https://github.com/login/oauth/authorize", responseType: "token")
        
        let handle = oauthswift.authorize(withCallbackURL: "app-name://oauth-callback?code=", scope: "user+repo", state: "", success: { credential, response, parameters in
            print(credential.oauthToken)
        }, failure: { error in
            print(error.localizedDescription)
        })
    }

When I run it nothing is happening. success doesn't run, neither does failure.

Also, consumerKey and 'consumerKey' are filled in with the client ID and client secret on my end. app-name is also the actual name of the app on my end.

OAuth Provider (Twitter, Github, ..):

GitHub

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.0.0
  • v0.6
  • other: (v1.1.0)

Xcode version:

  • 8.0 (Swift 3.0)

  • 8.0 (Swift 2.3)

  • 7.3.1

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

  • objective c

Originally created by @dannymout on GitHub (Dec 30, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/328 ### Description: This is the code I'm using: ```` oauthswift = OAuth2Swift(consumerKey: "XXXXXXXXXXXXXXXXXXX", consumerSecret: "XXXXXXXXXXXXXXXXXXX", authorizeUrl: "https://github.com/login/oauth/authorize", responseType: "token") let handle = oauthswift.authorize(withCallbackURL: "app-name://oauth-callback?code=", scope: "user+repo", state: "", success: { credential, response, parameters in print(credential.oauthToken) }, failure: { error in print(error.localizedDescription) }) } ```` When I run it nothing is happening. `success` doesn't run, neither does `failure`. Also, `consumerKey` and 'consumerKey' are filled in with the client ID and client secret on my end. `app-name` is also the actual name of the app on my end. ### OAuth Provider (Twitter, Github, ..): GitHub ### OAuth Version: - [ ] Version 1 - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Manually ### Library version: - [ ] head - [ ] v1.0.0 - [ ] v0.6 - [x] other: (v1.1.0) ### Xcode version: - [x] 8.0 (Swift 3.0) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem 2026-03-03 16:46:38 +03:00
Author
Owner

@phimage commented on GitHub (Dec 31, 2016):

Try a no empty State
Try scope 'user', or encore scope (maybe there is an issue)

I don't know github callback URL recommandation but why there is "code="

<!-- gh-comment-id:269857247 --> @phimage commented on GitHub (Dec 31, 2016): Try a no empty State Try scope 'user', or encore scope (maybe there is an issue) I don't know github callback URL recommandation but why there is "code="
Author
Owner

@phimage commented on GitHub (Jan 1, 2017):

You describe normal oauth flow. So this must be done automatically by OAuthSwift

<!-- gh-comment-id:269890801 --> @phimage commented on GitHub (Jan 1, 2017): You describe normal oauth flow. So this must be done automatically by OAuthSwift
Author
Owner

@dannymout commented on GitHub (Jan 1, 2017):

Also, Xcode shows that there's no network activity from the app.

<!-- gh-comment-id:269920639 --> @dannymout commented on GitHub (Jan 1, 2017): Also, Xcode shows that there's no network activity from the app.
Author
Owner

@kpfefferle commented on GitHub (Jan 1, 2017):

@dannymout Did you set up the URL scheme to handle the GitHub redirect per the instructions here and here? This is required to handle the response from GitHub before either the success or failure closures will execute.

<!-- gh-comment-id:269923922 --> @kpfefferle commented on GitHub (Jan 1, 2017): @dannymout Did you set up the URL scheme to handle the GitHub redirect per the instructions [here](https://github.com/OAuthSwift/OAuthSwift#setting-url-schemes) and [here](https://github.com/OAuthSwift/OAuthSwift#handle-url-in-appdelegate)? This is required to handle the response from GitHub before either the success or failure closures will execute.
Author
Owner

@dannymout commented on GitHub (Jan 2, 2017):

@kpfefferle I forgot something in the AppDelegate, I put the if statement, but forgot to add something to the parameters.

<!-- gh-comment-id:270033500 --> @dannymout commented on GitHub (Jan 2, 2017): @kpfefferle I forgot something in the AppDelegate, I put the if statement, but forgot to add something to the parameters.
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#202
No description provided.