tumblr / jumblr

Tumblr API v2 Java Client
Apache License 2.0
278 stars 105 forks source link

Can't get Information about the authenticating user: Not Authorized #64

Closed azhwani closed 9 years ago

azhwani commented 9 years ago

Hi everyone, JTumblr failled to get Information about the authenticating user! com.tumblr.jumblr.exceptions.JumblrException: Not Authorized at com.tumblr.jumblr.JumblrClient.user(JumblrClient.java:83) Thanks in advance.

KevinTCoughlin commented 9 years ago

@azhwani are you authenticating prior to making the API call(s)? If so can you provide the sample code minus your security credentials?

azhwani commented 9 years ago

@KevinTCoughlin yes I'm authenticating prior to making the API requests! This morning everything worked well but after about two hours it failled again when I tried to get my following list ! I think it is something related to API calls limit !!

KevinTCoughlin commented 9 years ago

Yea that's possible. Have you looked at the x_ratelimit_* headers returned?

azhwani commented 9 years ago

No I never heard about it but I will absolutely check this out ! can you give me some further information! Thanks @KevinTCoughlin I really appreciate your help!

azhwani commented 9 years ago

Hii @KevinTCoughlin

I dont understand ! I can get my blog info successfully but I cant get my following list! it keeps returning this:

Exception in thread "AWT-EventQueue-0" com.tumblr.jumblr.exceptions.JumblrException: Not Authorized at com.tumblr.jumblr.request.RequestBuilder.clear(RequestBuilder.java:151) at com.tumblr.jumblr.request.RequestBuilder.get(RequestBuilder.java:92) at com.tumblr.jumblr.JumblrClient.user(JumblrClient.java:83) at com.tumblr.mine.MyTumblrManager.TumblrManager.getMyFollowing(TumblrManager.java:784) at com.tumblr.mine.MyTumblrManager.TumblrManager$5.actionPerformed(TumblrManager.java:648) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

does anyone experiencing this too ? please any help would be appreciated!

KevinTCoughlin commented 9 years ago

@azhwani I actually just had this same issue. Clearing my cookies, regenerating my token in the API console, copying and running the sample code for /user/following returned the correct output.

Can you try the following:

Here's my working code with the credentials removed:

final JumblrClient client = new JumblrClient("<token>", "<secret>");
client.setToken("<token>", "<secret>");

try {
    final List<Blog> blogs = client.userFollowing();
    blogs.size();
    // 20 
} catch(JumblrException e) {
    System.out.println(e.getMessage());
}
azhwani commented 9 years ago

Hi @KevinTCoughlin I tried everything u said but I still having same issue ! i run you sample code with new generated tokens and it does not work!

KevinTCoughlin commented 9 years ago

Are you using the correct tokens when instantiating your Jumblr client? I successfully got my following list using the above code when I used tokens that I had authorized for my blog.

final JumblrClient client = new JumblrClient("consumer_key", "consumer_secret");
client.setToken("oauth_token", "oauth_token_secret");

Make sure your consumer keys are first, then OAuth tokens for the blog you authorized in the following setToken call. I'm fairly certain this is an auth issue on your end because I was able to get it to work.

KevinTCoughlin commented 9 years ago

Closing this issue as I was unable to reproduce the error and could correct retrieve my authenticated blog's following list. @azhwani if this continues to happen I suggest opening a thread in the Tumblr API Google Group.

azhwani commented 9 years ago

@KevinTCoughlin Thank u so mutch for ur effort and replies everything works perfectly now :) Thanks again !

KevinTCoughlin commented 9 years ago

No problem, thanks for the follow up.