[java client jumblr] how to get customer key and secret key?

485 views
Skip to first unread message

Pasquale Franzese

unread,
May 7, 2013, 11:07:30 AM5/7/13
to tumbl...@googlegroups.com
Hi, I'm new to the environment and I'm struggling with the very basics of tumblr's java client.
In the example operations that I'm still trying to perform is requested to use a "customer key" and a "customer secret key", both distinct from oAuth keys.
The example code is:
// Create a new client
JumblrClient client = new JumblrClient("consumer_key", "consumer_secret");
client.setToken("oauth_token", "oauth_token_secret");

// Write the user's name
User user = client.user();
System.out.println(user.getName());

// And list their blogs
for (Blog blog : user.getBlogs()) {
    System.out.println("\t" + blog.getTitle());
}

// Like the most recent "lol" tag
client.tagged("lol").get(0).like();
How do I get the ("consumer_key", "consumer_secret"to correctly initialize the client? 
Thanks!

John Crepezzi

unread,
May 7, 2013, 11:08:23 AM5/7/13
to tumbl...@googlegroups.com
You can get the consumer key & secret for your application at http://www.tumblr.com/oauth/apps
Or register a new app if one doesn't exist


--
You received this message because you are subscribed to the Google Groups "Tumblr API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tumblr-api+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Pasquale Franzese

unread,
May 7, 2013, 12:06:49 PM5/7/13
to tumbl...@googlegroups.com
Did that already, there I can get only oAuth keys... I need the way to get the other two keys... I already tried using the oauth keys instead but it gives me an error at runtime and the app crashes at System.out.println(user.getName());
the error is:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:47)
at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:33)
at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:99)
at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:53)
at org.scribe.oauth.OAuth10aServiceImpl.signRequest(OAuth10aServiceImpl.java:76)
at com.tumblr.jumblr.request.RequestBuilder.sign(RequestBuilder.java:126)
at com.tumblr.jumblr.request.RequestBuilder.get(RequestBuilder.java:68)
at com.tumblr.jumblr.JumblrClient.user(JumblrClient.java:64)
at tumblr.Tumblr.main(Tumblr.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 9 more
Java Result: 1

John Crepezzi

unread,
May 7, 2013, 2:30:44 PM5/7/13
to tumbl...@googlegroups.com
Actually those _are_ your consumer key & secret (i promise).
To get the other two keys, you'll need to go through a full OAuth workflow as your own user.

To make it a little easier..
We have a utility built into the Ruby client to generate these, you can do something like:

```
$ gem install ruby
$ tumblr # follow oauth flow as prompted
$ cat ~/.tumblr
```

Hope this helps!

Pasquale Franzese

unread,
May 7, 2013, 2:48:16 PM5/7/13
to tumbl...@googlegroups.com
Thank you a lot for your reply, sadly I don't understand what to do exactly (never worked with ruby...).
I tried to install rubygems, but on first command i get:
$ gem install ruby
ERROR:  Could not find a valid gem 'ruby' (>= 0) in any repository
ERROR:  Possible alternatives: ruby

also, the second one would require tumblr's ruby client, right?

Thank you again, you are really saving me ^^

John Crepezzi

unread,
May 7, 2013, 2:50:43 PM5/7/13
to tumbl...@googlegroups.com
haha woops - `gem install tumblr_client` (hits self in head)

Pasquale Franzese

unread,
May 7, 2013, 2:59:52 PM5/7/13
to tumbl...@googlegroups.com
Update:
I managed to install the client, dumb of me not to think the solution immediately:
$  sudo gem install tumblr_client
Now following the rest

Thank you again!!!

Pasquale Franzese

unread,
May 7, 2013, 3:00:38 PM5/7/13
to tumbl...@googlegroups.com
XD Didn't read this on time, thank you again!!!

Pasquale Franzese

unread,
May 7, 2013, 3:32:23 PM5/7/13
to tumbl...@googlegroups.com
I solved that problem, thank you a lot!

To the benefit of whoever comes after:
i first installed rubygem with

$ sudo apt-get install rubygems

then installed tumblr client

$ gem install tumblr_client

 and used it

$ tumblr

it asked me to give oAuth keys (secret and normal) and answered with a link containing a public token, I pasted it in a browser and got an auth request, clicked on ok, then got a redirect to my callback url with the token public & secret keys as params.

Thank you again, I'll open a new discussion topic with my new problems tomorrow (I still get the same errors in the program ): but now i know the codes are not responsible)

John Crepezzi

unread,
May 7, 2013, 3:33:48 PM5/7/13
to tumbl...@googlegroups.com
Sounds good - glad you got your keys successfully!

Pasquale Franzese

unread,
May 7, 2013, 3:35:10 PM5/7/13
to tumbl...@googlegroups.com
ERRATA CORRIGE:
the callback url has the oauth_verifier value that the program asks to complete the operation, after you paste it  in the terminal the keys will be in the .tumblr file on the home folder (where I installed everything) not in the callback url

Pasquale Franzese

unread,
May 7, 2013, 3:36:22 PM5/7/13
to tumbl...@googlegroups.com
Yes, I really owe you a favor!
Reply all
Reply to author
Forward
0 new messages