Karl
Karl

Reputation: 595

Twitter API call to get access_token of OAuth only with javascript

I am trying to figure if I can authenticate users with Twitter OAuth in one simple ajax call. I need to use javascript because I am building the application on iOS with Phonegap. Here is the api used for Facebook to directly retrieve the access_token for that user once they sign in and authorize app.

What would be the Twitter equivalent of this API call if there is one?

https://www.facebook.com/dialog/oauth?
    client_id=YOUR_APP_ID
   &redirect_uri=YOUR_REDIRECT_URI
   &scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES
   &response_type=token

I have already tried applying the 3 legged authentication, to no avail of course. I prefer not using the pin authorization method.

Any help would be appreciated, thank you so much everyone!

Upvotes: 0

Views: 1342

Answers (2)

Jon Nylander
Jon Nylander

Reputation: 8963

+1 for Mark S's as xAuth is a compelling option for user experience and ease of implementation. If you can get Twitter to approve it I would definitely do that.

You could also register your iOS app with a custom URL that you can use as a callback from the authorization step. This would allow you to receive the oauth_verifier directly to your app without going via a user entering a PIN.

Another tip is to simply scrape the oauth_verifier from any valid callback. Once the WebView loads it you can check the WebView's address property for the oauth_verifier parameter. Once the verifier is yours you will be able to get the access token.

Upvotes: 1

Mark S.
Mark S.

Reputation: 4017

Will xAuth meet your needs. According to Twitter, "xAuth allows desktop and mobile applications to skip the request_token and authorize steps and jump right to the access_token step." The only caveat is that you need to request permission from Twitter for your app to use xAuth.

Upvotes: 2

Related Questions