简体   繁体   English

为什么在 edX 安装中调用 api/user/v1/accounts 端点并不总是提供名称和 email 地址?

[英]Why would a call to the api/user/v1/accounts endpoint in an edX installation not always supply the name and email address?

In calling our edX installation's api/user/v1/accounts endpoint for some users, I get more information than other users, however the users are defined similarly.在为某些用户调用我们的 edX 安装的 api/user/v1/accounts 端点时,我得到的信息比其他用户多,但是用户的定义类似。 Any idea what is not configured correctly?知道什么配置不正确吗?

To compare, this is what is expected:比较一下,这是预期的:

{
    "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"
}

And this is what I get with another user defined:这就是我与另一个用户定义的结果:

{
    "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"
}

The later is missing the name and email .后者缺少nameemail

The issue is caused by the permissions of the user that one uses to process xapi calls.该问题是由用于处理 xapi 调用的用户的权限引起的。
When you first define a user, at least for us, we created that account using oauth2.当您第一次定义用户时,至少对我们而言,我们使用 oauth2 创建了该帐户。 We went to xyzedx.com/admin/oauth2/client.我们去了 xyzedx.com/admin/oauth2/client。

That will supply you with the client id and client secret.这将为您提供客户端 ID 和客户端密码。

However, what we failed to do is then manage that user's permissions.但是,我们没有做的是管理该用户的权限。 These can be set at xyzedx.com/admin/auth/user.这些可以在 xyzedx.com/admin/auth/user 中设置。 There you need to set:在那里你需要设置:

  • Active: True主动:真
  • Staff User: True员工用户:真
  • User permissions, allocate all of the the "oauth2|"用户权限,分配所有的“oauth2|” ( [access token | refresh token] * [change, add, delete]). ([访问令牌 | 刷新令牌] * [更改、添加、删除])。

To test, we used Postman.为了测试,我们使用了 Postman。 If you are unfamiliar with how to use such when you need an access token, then here's how that is done.如果您在需要访问令牌时不熟悉如何使用它,那么这里是如何完成的。

For the following example call to work:对于以下示例调用工作:

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

With the GET method, in the header for the http request, one provides: - accept: application/json - content-Type: application/json使用 GET 方法,在 http 请求的 header 中,提供: - 接受:application/json - content-Type:application/json

Then set the Authorisation tab, specifically chosing OAuth 2.0 , and Get new Access Token .然后设置 Authorization 选项卡,特别选择OAuth 2.0Get new Access Token

在此处输入图像描述

There you will supply the credentials you got from the EdX Oauth2 configuration:在那里,您将提供从 EdX Oauth2 配置中获得的凭据:

在此处输入图像描述

You need to configure this to add the token to the "Header" (this will create another entry in your "Header" table; and then elect to Use Token .您需要对其进行配置以将令牌添加到“标题”(这将在您的“标题”表中创建另一个条目;然后选择Use Token

Then you Send the call.然后你Send呼叫。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM