OAuth Vimeo with Scribe (Java) [英] OAuth Vimeo with Scribe (Java)

查看:57
本文介绍了OAuth Vimeo with Scribe (Java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:您可以通过将我引导到一个很好地解释了如何与 Web 服务交互的地方来帮助我解决这个问题.但是对于这个特定问题的帮助将不胜感激!

Note: You may be able to help me with this just by directing me to a place that explains well how to interface with web services. But help on this specific problem would be greatly appreciated!

我很难理解 OAuth 的工作原理.我正在尝试开发一个桌面应用程序,它将向 Vimeo 上的帐户上传一堆视频.我尝试对 Scribe API 及其 示例.不幸的是,Scribe 没有 Vimeo 示例,因此我一直在尝试更改 Facebook 示例以使其适用于 Vimeo.关于这一切如何运作的信息很少(我已经能够1:找到,2:理解).以下是我所拥有的代码和错误:

I'm having a really hard time understanding how OAuth works. I'm trying to develop a desktop application which will upload a bunch of videos to accounts on Vimeo. I've tried tinkering a bit with the Scribe API and its examples. Scribe doesn't have a Vimeo example unfortunately, so I've been trying to alter the Facebook example to make it work for Vimeo. There's very little information on how this all works (that I've been able to 1: find, 2: understand). Here's what I have as far as code and errors:

public class VimeoTest
{
  private static final String NETWORK_NAME = "Vimeo";
  private static final Token EMPTY_TOKEN = null;

  public static void main(String[] args)
  {
    // Replace these with your own api key and secret
    String apiKey = "MYAPIKEY";
    String apiSecret = "MYAPISECRET";
    OAuthService service = new ServiceBuilder()
                                  .provider(VimeoApi.class)
                                  .apiKey(apiKey)
                                  .apiSecret(apiSecret)
                                  .build();
    Scanner in = new Scanner(System.in);

    System.out.println("=== " + NETWORK_NAME + "'s OAuth Workflow ===");
    System.out.println();
    OAuthRequest orequest = new OAuthRequest(Verb.GET, "http://vimeo.com/api/rest/v2");
    orequest.addQuerystringParameter("method", "vimeo.test.null");
    Response send = orequest.send();
    System.out.println(send.getBody());

    // Obtain the Authorization URL
    System.out.println("Fetching the Authorization URL...");
    Token requestToken = service.getRequestToken();

    //Breaks on the line above.
    //But I think it's because the orequest.send() returned a 100 error code

    String authorizationUrl = service.getAuthorizationUrl(requestToken);
    System.out.println("Got the Authorization URL!");
    System.out.println("Now go and authorize Scribe here:");

    //I do NOT want to have to do this. Is there any other way I can have this authorize without going to a web browser to do this?

    System.out.println(authorizationUrl);
    System.out.println("And paste the authorization code here");
    System.out.print(">>");
    Verifier verifier = new Verifier(in.nextLine());
    System.out.println();

这是输出和错误:

=== Vimeo's OAuth Workflow ===

1.0
<?xml version="1.0" encoding="utf-8"?>
<rsp generated_in="0.0069" stat="fail">
  <err code="100" expl="The API key passed was not valid" msg="Invalid API Key" />
</rsp>
Fetching the Authorization URL...
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:118)
    at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:63)
    at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:43)
    at autouploadermodel.VimeoTest.main(VimeoTest.java:38)
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)
    ... 6 more
Java Result: 1

无论如何,我敢打赌这真的很简单,但我只是不明白如何与 Web 服务交互.感谢您的帮助!

Anyway, I'll bet this is really simple, but I just don't understand how to interface with web services. Thanks for any help!

推荐答案

您需要包含 apache commons codec 在你的类路径上

You need to include apache commons codec on your classpath

这篇关于OAuth Vimeo with Scribe (Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆