Twitter API ME 1.8: Now with OAuth support

  22 posts   Feedicon  
Replies: 21 - Last Post: May 16, 2012 14:15
by: Ernandes Mourao Junior
showing 1 - 20 of 22
« Previous 1
 
Posted: October 07, 2011 11:10 by Ernandes Mourao Junior
Hi, all

I am pleased to announce hereby that Twitter API ME 1.8 is now released with great news.

This new version is very special, because it comes with full support to OAuth. Since Twitter changed its Application Permission Model, requiring apps to use OAuth to have access to user's direct messages, Twitter API ME developers were not longer able to access DMs from their apps. Before v1.8, only xAuth was supported.

Other great thing about OAuth is that developers will no longer need to request xAuth permission to Twitter for their apps keys, in order to start working with the API. Since OAuth flow is more secure, Twitter trusts promptly any registered app, because there is no way for apps to get access to user's password. So, no more you have to wait days or until your app is done, so Twitter decides to grant you permission.

It is also important to point out, OAuth is available for all platforms supported: Java ME, Android and RIM.

Besides OAuth, Twitter API ME 1.8 comes with other news:

* Possibility to configure additional connection parameters for RIM platform.
* Improved RIM connection string solving the issue of when the devices is subscribed to BIS.
* Geo-located Trend search based on Yahoo! Where On Earth ID.
* Bug fixes and replacement of some deprecated Twitter API's resources.

I am really glad to have one more version of this successful project released. In addition, I would also like to thank everybody that contributed with the project, reporting bugs and requesting new features through our Express Support.

I strongly recommend you to migrate to v1.8 right away. So, download it now. I also prepared some sample apps to help developers to understand how to integrate OAuth into their apps. Have fun!

Twitter API ME - Home
http://kenai.com/projects/twitterapime

Twitter API ME - Download
http://kenai.com/projects/twitterapime/downloads/directory/1.8

Twitter API ME - Sample Apps using OAuth
http://kenai.com/projects/twitterapime/downloads/directory/Miscellaneous

I hope everybody enjoy it!

Regards,
 
Posted: January 03, 2012 09:48 by omgimanoob
Great api, I signed up with Twitter for consumer key and secret, paste them to the sample codes and it works like a charm!

For BlackBerry oAuth, is OOB the only option? Otherewise what do we put in for the callback url?
 
Posted: January 03, 2012 16:44 by Ernandes Mourao Junior
For BB you have both: full oauth and oob. Any valid url. e.g., your website's. Btw, this url must be registered in app's page on Twitter dev website.
 
Posted: May 16, 2012 12:12 by amrsawy
so how can i customize the library for a specific rim connection? is there any sample code?
 
Posted: May 16, 2012 14:15 by Ernandes Mourao Junior
Hi,

Check out the methods setAppendConnectionParameters() and setConnectionParameters() of the class impl.rim.com.twitterapime.io.HttpConnectionImpl.

Regards,

Support this project:
Donate now!
 
Posted: October 21, 2011 05:47 by sathvik
Hi,
I am trying to use Twitter api me v1.8 for Android with OAuth, Its a very good library but not able to get it work till now.

I have one query,
What has to be the callback url ?
If I specify empty callback url , Oauth flow is halted at getting verification pin,
because there is no way of extracting from webview. (apart from javascript hack)

According to my understanding this will be taken care by library, so I am definitely missing something here,
few things that might be causing this according to me is,
1. I have not given any callback url in the twitter app registration form.
2. If I have to give callback url while registration, Is dummy url ok.
3. If I don't give callback url during app registration, what is the callback url to be specified in the code ?


Thank you.
 
Posted: October 21, 2011 11:51 by Ernandes Mourao Junior
"What has to be the callback url ?"

Any valid URL, for instance, your website's one or any web address you have. You set this url in your app's page at dev.twitter.com. For further info, check this:

http://kenai.com/projects/twitterapime/pages/Home#AuthOAuth

When you left the url callback null, it triggers the out-of-band mode. For further info, check this:

http://kenai.com/projects/twitterapime/pages/Home#AuthOOB

Regards,
 
Posted: October 24, 2011 11:33 by sathvik
Hi,

I gave callback url and it opens webview, but authentication is failing, with message oauth_access_token failed, Hard to debug, difficult to understand why its happening, I am giving all credential data as specified in my dev.twitter.com page. !

Any clue as to how can I debug this and understand why its happening ? I am using the sample code provided , with consumer secret , consumer key , callback url accordingly.
 
Posted: October 24, 2011 12:21 by Ernandes Mourao Junior
Try to run on a real device.
 
Posted: October 24, 2011 12:47 by sathvik
Thanks, but I have tried in both emulator and device.
My settings are GMT +5:30 , that might cause any problem ? Since timings are involved in OAuth process.
 
Posted: October 24, 2011 16:13 by Ernandes Mourao Junior
Yes! They do, Just make sure your timezone and date/time are correct on your emulator/device. If it does not work, try a different timezone.
 
Posted: November 30, 2011 14:15 by shizzo
What fixed this for me was ensuring that the callback URL set in dev.twitter.com's OAuth config for the app matched the private final String CALLBACK_URL in code.

Cheers, Shiraz.
 
Posted: December 01, 2011 11:43 by Ernandes Mourao Junior
Exactly!
 
Posted: October 25, 2011 20:43 by eoszak
First of all, excellent job! Very clean and easy to understand! I've been searching around for a while and nothing made sense until I found your project.

I have an android project that uses Twitter to authenticate using OAuth, then uses the person's username to post info to a separate unrelated website (ensures unique usernames and authentication without storing passwords or personal info on the phone). Everything works fine until I get to the point where Twitter returns a PIN code and says "Go back to the app and enter the PIN to complete the authorization process". I have the callback url in dev.twitter.com set to empty, and the callbackurl in the app set to "oob". The webview remains on the PIN screen, and clicking the back button goes back to the app, but not in the intended manner. What am I missing to pass control back to the app and have the setOAuthListener take over? I included the snippet of code below (activity implements OAuthDialogListener):

WebView webView = new WebView(this);
setContentView(webView);
//
WebViewOAuthDialogWrapper pageWrapper =
new WebViewOAuthDialogWrapper(webView);
//
pageWrapper.setConsumerKey(OAUTH_CONSUMER_KEY);
pageWrapper.setConsumerSecret(OAUTH_CONSUMER_SECRET);
pageWrapper.setCallbackUrl(CALLBACKURL);
//
pageWrapper.setOAuthListener(new OAuthDialogListener() {

/**Callback when user authorizes the app to access the account.*/
public void onAuthorize(Token token) {
Credential c = new Credential(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, token);
UserAccountManager m = UserAccountManager.getInstance(c);
try {
if (m.verifyCredential()) {
String twitter_username = token.getUsername();
//
showMessage(twitter_username);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LimitExceededException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**Callback when user denies the app to access the account.*/
public void onAccessDenied(String message) {}
/**Callback when any error happens during authentication.*/
public void onFail(String message, String description) {}
});

Thank you!

Eric

UPDATE: I solved my own problem! My particular issue was I needed to use a custom scheme in the manifest and make that the callbackurl, like this:

in the Intent filter of the particular class in the manifest, add this element:
<data android:scheme="<class name without .java>" android:host="Full name of application workspace ex: com.workspace.appname" />

Then in the class itself, where I declared the CALLBACKURL I set it like so:

public final String CALLBACKURL = "com.workspace.appname://class";

Finally, I set the Callback URL in dev.twitter.com for the app to be any URL, as long as it's properly formed (http://www.domain.com). Worked like a champ!

Thanks again for a great resource!
 
Posted: December 15, 2011 08:03 by welsenKiriono
Thanx for this library in my blackberry application...
I've already tried it, i can success to login and get redirect to callback url..
But, i dunno why void public void onAuthorize(Token token) is not invoked at all...
Thanx..
 
Posted: December 19, 2011 16:02 by Ernandes Mourao Junior
Maybe you are forgetting to register the listener:

BrowserContentManager browserManager = ...;
BrowserContentManagerOAuthDialogWrapper page = new BrowserContentManagerOAuthDialogWrapper(browserManager);

page.setOAuthListener(new OAuthDialogListener() {
    public void onAuthorize(Token token) {
        //grab the token here.
    }
});

Regards,
 
Posted: December 21, 2011 02:46 by welsenKiriono
Thanx for the answer...
I'm using your sample for OAuth login in blackberry
in that sample,

BrowserContentManager browserMngr = new BrowserContentManager(0);
RenderingOptions rendOptions = browserMngr.getRenderingSession().getRenderingOptions();
rendOptions.setProperty(
RenderingOptions.CORE_OPTIONS_GUID,
RenderingOptions.SHOW_IMAGES_IN_HTML,
false);
add(browserMngr);
OAuthDialogWrapper pageWrapper = new BrowserContentManagerOAuthDialogWrapper(browserMngr);

i'm confused which class i have to use, OAuthDialogWrapper or BrowserContentManagerOAuthDialogWrapper ??
I have tried using OAuthDialogWrapper in BB BOLD 9700, it's worked..
But if i'm using in BB BOLD 9780, it's not worked...
 
Posted: December 22, 2011 11:53 by Ernandes Mourao Junior
Hi,

For Blackberry you must use BrowserContentManagerOAuthDialogWrapper class. OAuthDialogWrapper is just the super class of BrowserContentManagerOAuthDialogWrapper.

I have not tested this lib on RIM OS 6 (BOLD 9780).

Could you try do identify the failure point?

Regards,
 
Posted: December 27, 2011 11:09 by Rupal
Hi,,
I'm using Twitter API ME , code is working fine, after succesfull login to twitter, it is showing a message about 'Successfull authentication', I want to skip this step..how can I do that?

My code is as below..

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

WebView webView = new WebView(this);
setContentView(webView);

WebViewOAuthDialogWrapper pageWrapper =
new WebViewOAuthDialogWrapper(webView);

pageWrapper.setConsumerKey(AppConstants.TWITTER_CONSUMER_KEY);
pageWrapper.setConsumerSecret(AppConstants.TWITTER_CONSUMER_SECRET);
pageWrapper.setCallbackUrl(AppConstants.TWITTER_CALLBACK_URL);
pageWrapper.setOAuthListener(this);

pageWrapper.login();

}


Thanks in advance !
 
Posted: December 27, 2011 12:51 by Ernandes Mourao Junior
You can disable is by setting "false" setEnableCustomResultPages() or change the result page of each step, using the methods setCustomSuccessPageHtml(), setCustomDeniedPageHtml() and setCustomErrorPageHtml().

Let me know whether it works for you.
showing 1 - 20 of 22
« Previous 1
Replies: 21 - Last Post: May 16, 2012 14:15
by: Ernandes Mourao Junior
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close