[GH-ISSUE #181] Redirect URI hostname must match #106

Closed
opened 2026-03-03 16:45:44 +03:00 by kerem · 5 comments
Owner

Originally created by @rustanacexd on GitHub (Feb 9, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/181

I am using oauth2 for eventbrite but I am getting this error: ``Redirect URI hostname must match`

here is my code

let oauthswift = OAuth2Swift(
            consumerKey:    "x",
            consumerSecret: "x",
            authorizeUrl:   "https://www.eventbrite.com/oauth/authorize",
            responseType:   "token"
        )

        oauthswift.authorize_url_handler = SafariURLHandler(viewController: self)

        oauthswift.authorizeWithCallbackURL(
            NSURL(string: "Tara://oauth-callback/eventbrite")!,
            scope: "", state:"",
            success: { credential, response, parameters in
                print(credential.oauth_token)
            },
            failure: { error in
                print(error.localizedDescription)
            }
        )

This is my url scheme - http://take.ms/f9Q0y

Originally created by @rustanacexd on GitHub (Feb 9, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/181 I am using oauth2 for eventbrite but I am getting this error: ``Redirect URI hostname must match` here is my code ``` let oauthswift = OAuth2Swift( consumerKey: "x", consumerSecret: "x", authorizeUrl: "https://www.eventbrite.com/oauth/authorize", responseType: "token" ) oauthswift.authorize_url_handler = SafariURLHandler(viewController: self) oauthswift.authorizeWithCallbackURL( NSURL(string: "Tara://oauth-callback/eventbrite")!, scope: "", state:"", success: { credential, response, parameters in print(credential.oauth_token) }, failure: { error in print(error.localizedDescription) } ) ``` This is my url scheme - http://take.ms/f9Q0y
kerem 2026-03-03 16:45:44 +03:00
Author
Owner

@phimage commented on GitHub (Feb 9, 2016):

Maybe you must declare the callback URL into evenbrite website. Many
providers want you to declare an URL white list

From doc :

To authenticate users via the API, you’ll need the following details (available on your apps page:

- Client Key: Identifies your app during the OAuth handshake. Not secret.
- Client Secret: Identifies your app during a server-side handshake. Secret.
- Redirect URI: The URI we’ll redirect users to once they approve your app. You need to set this in the Eventbrite app settings.

<!-- gh-comment-id:181728951 --> @phimage commented on GitHub (Feb 9, 2016): Maybe you must declare the callback URL into evenbrite website. Many providers want you to declare an URL white list From doc : ``` To authenticate users via the API, you’ll need the following details (available on your apps page: - Client Key: Identifies your app during the OAuth handshake. Not secret. - Client Secret: Identifies your app during a server-side handshake. Secret. - Redirect URI: The URI we’ll redirect users to once they approve your app. You need to set this in the Eventbrite app settings. ```
Author
Owner

@phimage commented on GitHub (Feb 9, 2016):

a google search show you that it's an Eventbrite message

and maybe custom url scheme is not supported yet (ie. Tara://)
https://twitter.com/eventbriteapi/status/590861041317187587
If callback/redirect url must be http
https://github.com/OAuthSwift/OAuthSwift/wiki/API-with-only-HTTP-scheme-into-callback-URL

<!-- gh-comment-id:181812038 --> @phimage commented on GitHub (Feb 9, 2016): a google search show you that it's an Eventbrite message and maybe custom url scheme is not supported yet (ie. Tara://) https://twitter.com/eventbriteapi/status/590861041317187587 If callback/redirect url must be http https://github.com/OAuthSwift/OAuthSwift/wiki/API-with-only-HTTP-scheme-into-callback-URL
Author
Owner

@rustanacexd commented on GitHub (Feb 9, 2016):

@phimage thanks i'll check it out.

<!-- gh-comment-id:182015308 --> @rustanacexd commented on GitHub (Feb 9, 2016): @phimage thanks i'll check it out.
Author
Owner

@rustanacexd commented on GitHub (Feb 10, 2016):

so I have this code

       let oauthswift = OAuth2Swift(
            consumerKey:    "XQH5AWPSEU4C25TBEF",
            consumerSecret: "DQFBX3OQNVA5SMLLSQ7TB7BQ7E5EOIX5R5Z36GQM4LDUCFISYW",
            authorizeUrl:   "https://www.eventbrite.com/oauth/authorize",
            responseType:   "token"
        )


        oauthswift.authorize_url_handler = OauthView()


        oauthswift.authorizeWithCallbackURL(
            NSURL(string: "")!,
            scope: "", state:"",
            success: { credential, response, parameters in
                print(credential.oauth_token)
            },
            failure: { error in
                print(error.localizedDescription)
            }
        )`

and then implemented a UIWebView

class OauthView: UIWebView, OAuthSwiftURLHandlerType{

    func handle(url: NSURL) {
        OAuthSwift.handleOpenURL(url)
    }

}

I get this error - No access_token, no code and no error provided by server
can you tell me what's wrong?

<!-- gh-comment-id:182204589 --> @rustanacexd commented on GitHub (Feb 10, 2016): so I have this code ``` let oauthswift = OAuth2Swift( consumerKey: "XQH5AWPSEU4C25TBEF", consumerSecret: "DQFBX3OQNVA5SMLLSQ7TB7BQ7E5EOIX5R5Z36GQM4LDUCFISYW", authorizeUrl: "https://www.eventbrite.com/oauth/authorize", responseType: "token" ) oauthswift.authorize_url_handler = OauthView() oauthswift.authorizeWithCallbackURL( NSURL(string: "")!, scope: "", state:"", success: { credential, response, parameters in print(credential.oauth_token) }, failure: { error in print(error.localizedDescription) } )` ``` and then implemented a UIWebView ``` class OauthView: UIWebView, OAuthSwiftURLHandlerType{ func handle(url: NSURL) { OAuthSwift.handleOpenURL(url) } } ``` I get this error - `No access_token, no code and no error provided by server` can you tell me what's wrong?
Author
Owner

@phimage commented on GitHub (Feb 10, 2016):

next time please open an other issue

handle method must not call OAuthSwift.handleOpenURL()
handle must load the url to a web view to let user login and authorize
then the website/provider will redirect to the callback url passed as argument (and OAuthSwift.handleOpenURL() will be call with an url containing information like token, using url scheme, or web view delegate)

then it's better to put a view controller as OAuthSwiftURLHandlerType instead of the view itself

see demo code or readme

<!-- gh-comment-id:182216248 --> @phimage commented on GitHub (Feb 10, 2016): next time please open an other issue handle method must not call OAuthSwift.handleOpenURL() handle must load the url to a web view to let user login and authorize then the website/provider will redirect to the callback url passed as argument (and OAuthSwift.handleOpenURL() will be call with an url containing information like token, using url scheme, or web view delegate) then it's better to put a view controller as OAuthSwiftURLHandlerType instead of the view itself see demo code or readme
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#106
No description provided.