0

在为某些用户调用我们的 edX 安装的 api/user/v1/accounts 端点时,我得到的信息比其他用户多,但是用户的定义类似。知道什么配置不正确吗?

比较一下,这是预期的:

{
    "username": "xapitest",
    "bio": null,
    "requires_parental_consent": true,
    "name": "Xapi Test",
    "secondary_email": null,
    "country": null,
    "social_links": [],
    "is_active": true,
    "profile_image": {
        "image_url_full": "https://online.xxxedx.com/static/images/profiles/default_500.4215dbe8010f.png",
        "image_url_large": "https://online.xxxedx.com/static/images/profiles/default_120.4a5e0900098e.png",
        "image_url_medium": "https://online.xxxedx.com/static/images/profiles/default_50.3455a6581573.png",
        "image_url_small": "https://online.xxxedx.com/static/images/profiles/default_30.deee7287e843.png",
        "has_image": false
    },
    "extended_profile": [],
    "year_of_birth": null,
    "level_of_education": null,
    "accomplishments_shared": false,
    "goals": "",
    "language_proficiencies": [],
    "gender": null,
    "account_privacy": "private",
    "mailing_address": "",
    "email": "xapitest@xxxedx.com",
    "date_joined": "2020-04-27T14:49:58Z"
}

这就是我与另一个用户定义的结果:

{
    "username": "Rolrox",
    "bio": null,
    "accomplishments_shared": false,
    "country": "HU",
    "social_links": [],
    "profile_image": {
        "image_url_full": "https://online.xxxedx.com/static/images/profiles/default_500.4215dbe8010f.png",
        "image_url_large": "https://online.xxxedx.com/static/images/profiles/default_120.4a5e0900098e.png",
        "image_url_medium": "https://online.xxxedx.com/static/images/profiles/default_50.3455a6581573.png",
        "image_url_small": "https://online.xxxedx.com/static/images/profiles/default_30.deee7287e843.png",
        "has_image": false
    },
    "time_zone": null,
    "language_proficiencies": [],
    "account_privacy": "all_users",
    "date_joined": "2020-04-28T10:25:59Z"
}

后者缺少nameand email

4

1 回答 1

0

该问题是由用于处理 xapi 调用的用户的权限引起的。
当您第一次定义用户时,至少对我们而言,我们使用 oauth2 创建了该帐户。我们去了 xyzedx.com/admin/oauth2/client。

这将为您提供客户端 ID 和客户端密码。

但是,我们没有做的是管理该用户的权限。这些可以在 xyzedx.com/admin/auth/user 中设置。在那里你需要设置:

  • 主动:真
  • 员工用户:真
  • 用户权限,分配所有的“oauth2|” ([访问令牌 | 刷新令牌] * [更改、添加、删除])。

为了测试,我们使用了 Postman。如果您在需要访问令牌时不熟悉如何使用它,那么这里是如何完成的。

对于以下示例调用工作:

https://xxxedx.com/api/user/v1/accounts/jbloggs

使用 GET 方法,在 http 请求的标头中,提供: - 接受:application/json - content-Type:application/json

然后设置授权选项卡,特别是选择OAuth 2.0Get new Access Token

在此处输入图像描述

在那里,您将提供从 EdX Oauth2 配置中获得的凭据:

在此处输入图像描述

您需要对其进行配置以将令牌添加到“标题”(这将在您的“标题”表中创建另一个条目;然后选择Use Token.

然后你Send打电话。

于 2020-04-29T11:10:08.900 回答