【问题标题】:OAuth requestToken for freelancer.com apifreelancer.com api 的 OAuth requestToken
【发布时间】:2011-07-28 10:35:54
【问题描述】:

有人用过freelancer.com api吗?我什至无法检索它的 requestToken。我想要它的Android。我尝试使用路标库,但它给出了以下错误

oauth.signpost.exception.OAuthNotAuthorizedException:授权失败(服务器回复 401)。如果使用者密钥不正确或签名不匹配,就会发生这种情况。

我正在使用正确的消费者密钥。同样的方法也适用于 twitter。

【问题讨论】:

    标签: android oauth signpost freelancer.com-api


    【解决方案1】:

    回复晚了,但你让它工作了吗? 那么,它适用于 Twitter,但不适用于 Freelancer? 我在 freelancer 中发现的一件事是,如果 OAuth 参数是在标头中发送的,它不会采用 OAuth 参数。您需要在 GET 或 POST 中提供 OAuth 参数。另一方面,Twitter 建议通过标头发送这些参数。

    【讨论】:

    • 我使用了 oauth-signpost 库。不确定它是否使用 GET 或标头机制。
    【解决方案2】:

    早期版本的路标仅在标头中实现 OAuth 参数。 freelanecer.com api 期望参数位于查询字符串中。最新版本的 Signpost 现在可以在查询字符串中实现 OAuth 参数。

    这是来自服务构建器的相关代码:

      /**
      * Configures the signature type, choose between header, querystring, etc. Defaults to Header
      *
      * @param scope The OAuth scope
      * @return the {@link ServiceBuilder} instance for method chaining
      */
      public ServiceBuilder signatureType(SignatureType type)
      {
         Preconditions.checkNotNull(type, "Signature type can't be null");
         this.signatureType = type;
        return this;
      }
    
      Service = new ServiceBuilder()
                        .provider(FreelancerApi.class)
                        .apiKey(consumer)
                        .apiSecret(secret)
                        .callback("oob")
                        .signatureType(SignatureType.QueryString)
                        .build();
    

    【讨论】:

    • 哦,好的。我在哪里使用此代码?在特定的班级还是什么?
    • 我在上面编辑了我的回复,以便您了解如何在查询字符串模式下初始化服务。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 2014-07-12
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多