Verticon
Verticon

Reputation: 2513

Twitter API: How Do I Create a Protocol Only Callback URL?

In Twitter's Developer Documentation we can read the following:

Mobile apps with app-specific protocols must use just the protocol
Example:
    You want to use example://authorize as your callback URL
    Add this to both your Twitter app dashboard and your call to oauth/request_token: example://

However; in the Developer's Dashboard I am not able to enter a protocol only URL, or any URL beginning with other than http or https.

Twitter's Developer Dashboard

My reason for wanting a protocol only URL is so that I can use in an iOS app that uses OAuthSwift to access web APIs.

Any ideas anybody?

Upvotes: 1

Views: 552

Answers (1)

Verticon
Verticon

Reputation: 2513

I haven't found the answer to the original question but I do have an excellent work around. So, for anyone else who might land here:

The web app at https://oauthswift.herokuapp.com/callback will perform redirections. If you access that web site with the url https://oauthswift.herokuapp.com/callback/target then it will redirect to oauth-swift://oauth-callback/target.

So:

  1. In the Twitter Dashboard enter https://oauthswift.herokuapp.com/callback/SomeName for your app's callback URL
  2. Register oauth-swift as a URL scheme in your iOS app's URL Types
  3. In your iOS app, use https://oauthswift.herokuapp.com/callback/SomeName as the callback URL for the OAuth authorization request.

Voila. Twitter will redirect to https://oauthswift.herokuapp.com/callback/SomeName which will in turn redirect to oauth-swift://oauth-callback/SomeName, allowing your iOS app to regain control of the flow.

If you find any of this confusing then this might help: http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

Upvotes: 1

Related Questions