【问题标题】:Implementing Withings api in android在android中实现Withings api
【发布时间】:2015-01-05 12:14:59
【问题描述】:

我正在尝试在 android 中实现 withings api。能够通过“google auth”实现进行身份验证,但无法访问 api,因为“oauth_nonce”是未知的,我不知道如何生成它。如果您知道流程,请分享,如果您使用任何方法实现了 withings api,请分享。

【问题讨论】:

    标签: android withings


    【解决方案1】:

    oauth_nonce 是一个随机字符串,它必须是唯一的。

    我正在开发一个混合应用程序,所以我在 AngularJS 中生成 oauth_nonce 的代码是:

    .factory('RandomFactory', function() {
      return ({
        string: function(length, chars) {
          var result = '';
          for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
          return result;
        }
      })
    
    var oauth_nonce = RandomFactory.string(32, "1234567890qwertyuiopasdfghjklzxcvbnm");
    

    但我认为你可以在 Java 中轻松做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 1970-01-01
      相关资源
      最近更新 更多