【问题标题】:Desire2Learn issue with calling API's调用 API 的 Desire2Learn 问题
【发布时间】:2014-08-08 14:48:42
【问题描述】:

我正在尝试使用 valance api 来调用一些方法。我正在使用 https://apitesttool.desire2learnvalence.com 进行身份验证,从那里获取 UserId 和 UserKey。现在很困惑我应该在 x_a - x_d 参数中传递什么来获取组织信息。

无论我通过什么,我都会收到 403 禁止和不正确的令牌异常。

请一些人帮忙。我正在传递参数。

x_a : 应用程序 ID

x_b : 用户 ID(我从 https://apitesttool.desire2learnvalence.com 得到这个)

x_c : private String calculateParameterExpectation( String key, String httpMethod, String apiPath, long timestamp) { String unsignedResult = String.format("%s&%s&%s", httpMethod, apiPath, timestamp); System.out.println(unsignedResult); String signedResult = D2LSigner.getBase64HashString(key, unsignedResult); return signedResult; } Where key is the App Key

x_d : private String calculateParameterExpectation( String key, String httpMethod, String apiPath, long timestamp) { String unsignedResult = String.format("%s&%s&%s", httpMethod, apiPath, timestamp); System.out.println(unsignedResult); String signedResult = D2LSigner.getBase64HashString(key, unsignedResult); return signedResult; } Where key is the User Signature that i got from https://apitesttool.desire2learnvalence.com

我不确定做错了什么。

【问题讨论】:

    标签: desire2learn


    【解决方案1】:

    请注意,每个后端服务会生成一个唯一的用户ID/密钥对,以与每个用户和每个应用程序ID一起使用,@ 987654321@.

    这明确意味着用户 ID/密钥对不能从一个应用程序转移到另一个应用程序。它们也不能从一个后端服务转移到另一个后端服务——每个使用 API 的应用程序都应该请求自己的用户 ID/密钥对,以便代表每个不同的用户进行调用。即使您在使用 api-test 工具时使用了您的 App ID/Key,除非您将该工具指向您实际调用 API 的同一后端服务,否则您不会取回一个用户 ID/密钥对,您可以在以后进行 API 调用(针对另一个服务)。

    还请注意,签名机制要求您使用 大写 版本的 http-method 字符串(因此是 GET,而不是 get),并且它要求您使用api 路径字符串的 小写 版本(因此是 /d2l/auth/api/token,而不是 /D2L/AUTH/API/TOKEN)。如果您将 api-test 工具指向您想要进行 API 调用的同一 LMS,并且您使用与 api-test 工具相同的 App ID/Key 对,就像您在生产中使用的一样代码,然后我会设法确保您正在格式化您的基本字符串完全适合签名。

    我还鼓励您更充分地使用 D2L 自己的客户端 SDK 库来进行应用程序/用户上下文管理和签名,而不是仅使用库中的原始签名调用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-10
      • 2018-05-14
      • 1970-01-01
      相关资源
      最近更新 更多