[GH-ISSUE #345] Twitter OAuth throws Desktop applications only support the oauth_callback value 'oob' on iOS app #218

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

Originally created by @MaikoHermans on GitHub (Mar 3, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/345

Description:

So I'm trying to get oauth2 working but that doesn't seem to work since it will show me a page saying

Whoa there!
There is no request token for this page. That's the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

Where I have this piece of code

let oauthswift = OAuth2Swift(
            consumerKey: Twitter.consumerKey,
            consumerSecret: Twitter.consumerSecret,
            authorizeUrl: Twitter.authorizeURL,
            accessTokenUrl: Twitter.accessTokenURL,
            responseType: Twitter.responseType!)

let state = generateState(withLength: 20)
        
        oauthswift.authorize(
            withCallbackURL: "https://oauthswift.herokuapp.com/callback/twitter",
            scope: "",
            state: state,
            success: { credential, response, parameters in
                print("logged in with \(credential), with response \(response) and parameters \(parameters)")
            },
            failure: { error in
                print("error occured \(error.localizedDescription)")
            }
        )

Then I moved on to trying it with oauth1 which gives me the error
Desktop applications only support the auth_callback value 'oob' while I'm obviously trying to do this from a iOS app.

The code I have for this is as follows

let oauthTwitter = OAuth1Swift(
            consumerKey: "myKey",
            consumerSecret: "mySecret",
            requestTokenUrl: "https://api.twitter.com/oauth/request_token",
            authorizeUrl: "https://api.twitter.com/oauth/authorize",
            accessTokenUrl: "https://api.twitter.com/oauth/access_token")
 
oauthswift.authorize(
            withCallbackURL: "https://oauthswift.herokuapp.com/callback/twitter",
            scope: "",
            state: state,
            success: { credential, response, parameters in
                print("logged in with \(credential), with response \(response) and parameters \(parameters)")
            },
            failure: { error in
                print("error occured \(error.localizedDescription)")
            }
        )

I hope someone is able to tell me where I'm going wrong

OAuth Provider (Twitter):

OAuth Version:

  • Version
  • 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: (Please fill in the version you are using.)

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

Originally created by @MaikoHermans on GitHub (Mar 3, 2017). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/345 ### Description: So I'm trying to get oauth2 working but that doesn't seem to work since it will show me a page saying > Whoa there! > There is no request token for this page. That's the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake. Where I have this piece of code ``` swift let oauthswift = OAuth2Swift( consumerKey: Twitter.consumerKey, consumerSecret: Twitter.consumerSecret, authorizeUrl: Twitter.authorizeURL, accessTokenUrl: Twitter.accessTokenURL, responseType: Twitter.responseType!) let state = generateState(withLength: 20) oauthswift.authorize( withCallbackURL: "https://oauthswift.herokuapp.com/callback/twitter", scope: "", state: state, success: { credential, response, parameters in print("logged in with \(credential), with response \(response) and parameters \(parameters)") }, failure: { error in print("error occured \(error.localizedDescription)") } ) ``` Then I moved on to trying it with oauth1 which gives me the error `Desktop applications only support the auth_callback value 'oob'` while I'm obviously trying to do this from a iOS app. The code I have for this is as follows ``` swift let oauthTwitter = OAuth1Swift( consumerKey: "myKey", consumerSecret: "mySecret", requestTokenUrl: "https://api.twitter.com/oauth/request_token", authorizeUrl: "https://api.twitter.com/oauth/authorize", accessTokenUrl: "https://api.twitter.com/oauth/access_token") oauthswift.authorize( withCallbackURL: "https://oauthswift.herokuapp.com/callback/twitter", scope: "", state: state, success: { credential, response, parameters in print("logged in with \(credential), with response \(response) and parameters \(parameters)") }, failure: { error in print("error occured \(error.localizedDescription)") } ) ``` I hope someone is able to tell me where I'm going wrong ### OAuth Provider (Twitter): ### OAuth Version: - [x] Version - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Manually ### Library version: - [ ] head - [x] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### 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 closed this issue 2026-03-03 16:46:46 +03:00
Author
Owner

@phimage commented on GitHub (Mar 5, 2017):

Did you declare in twitter website your callbackurl?

"https://oauthswift.herokuapp.com/callback/twitter" is juste for demo purpose, this redirect to oauthswift://, make your own url scheme

<!-- gh-comment-id:284247581 --> @phimage commented on GitHub (Mar 5, 2017): Did you declare in twitter website your callbackurl? "https://oauthswift.herokuapp.com/callback/twitter" is juste for demo purpose, this redirect to oauthswift://, make your own url scheme
Author
Owner

@MaikoHermans commented on GitHub (Mar 6, 2017):

Alright I'm a little fussy on what the callback URL should do. When I set the callbackurl in twitter it will let me load the authorization page without an error but it will then redirect me to the given url and I can't figure out how to just let it close.

<!-- gh-comment-id:284332466 --> @MaikoHermans commented on GitHub (Mar 6, 2017): Alright I'm a little fussy on what the callback URL should do. When I set the callbackurl in twitter it will let me load the authorization page without an error but it will then redirect me to the given url and I can't figure out how to just let it close.
Author
Owner

@phimage commented on GitHub (Mar 6, 2017):

did you follow the readme?
add an url scheme to your app?

a callback is a callback, twitter call this url and then your app must get information using for instance the url scheme and calling OAuthSwift.handle(url: url)

<!-- gh-comment-id:284393571 --> @phimage commented on GitHub (Mar 6, 2017): did you follow the readme? add an url scheme to your app? a callback is a callback, twitter call this url and then your app must get information using for instance the url scheme and calling OAuthSwift.handle(url: url)
Author
Owner

@MaikoHermans commented on GitHub (Mar 7, 2017):

Yeah I figured it out I did set the url scheme just did it wrong because I added a _ in it that's why it wouldn't work.

<!-- gh-comment-id:284655958 --> @MaikoHermans commented on GitHub (Mar 7, 2017): Yeah I figured it out I did set the url scheme just did it wrong because I added a `_` in it that's why it wouldn't work.
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#218
No description provided.