[英]Unable to authenticate users for an app in Fiware Lab KeyRock instance
我已经在Keyrock中注册了两个用户(全球Fiware Labs实例位于https://account.lab.fiware.org )
我可以使用Shell脚本对用户“ Robin”进行身份验证以获取访问令牌。 在shell脚本中,我传入了Applications Client ID和Client secret。 我还传递了“ Robin”用户的用户名和密码。 shell脚本在此处(此https://raw.githubusercontent.com/Bitergia/fiware-chanchan-docker/master/images/pep-wilma/4.3.0/auth-token.sh的更改副本):
#!/bin/bash
if [ $# -lt 2 ] ; then
echo "auth-token: missing parameters."
echo "Usage: auth-token <user-email> <password>"
exit 1
fi
# Retrieve X-Auth-Token to make request against the protected resource
function get_token () {
if [ $# -lt 2 ] ; then
echo "get_token: missing parameters."
echo "Usage: get_token <user-email> <password>"
exit 1
fi
local _user=$1
local _pass=$2
# Retrieve Client ID and client Secret Automatically
CLIENT_ID="e2c095aa42414e75b9ac4d760f4c625a"
CLIENT_SECRET="****"
# Generate the Authentication Header for the request
AUTH_HEADER="$(echo -n ${CLIENT_ID}:${CLIENT_SECRET} | base64)"
# Define headers
CONTENT_TYPE="\"Content-Type: application/x-www-form-urlencoded\""
AUTH_BASIC="\"Authorization: Basic ${AUTH_HEADER}\""
# Define data to send
DATA="'grant_type=password&username=${_user}&password=${_pass}&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}'"
# Create the request
REQUEST="curl -s --insecure -i --header ${AUTH_BASIC} --header ${CONTENT_TYPE} -X POST https://account.lab.fiware.org/oauth2/token -d ${DATA}"
XAUTH_TOKEN="$(eval ${REQUEST})"
echo "Request: ${REQUEST}"
echo "X-Auth-Token for '${_user}': ${XAUTH_TOKEN}"
}
get_token $1 $2
然而
我无法获得用户“ Robin Viewer”的访问令牌。 我从Keyrock收到的消息是:
{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
我假设在Keyrock用户界面中为Babbler应用程序授权用户“ Robin查看器”就足够了。 我在这里想念什么?
似乎/oauth2/token?grant_type=password
组合仅适用于资源所有者,这正是我所看到的。
因此,似乎我们仅限于使用以下请求请求访问令牌: /oauth2/authorize?response_type=token&client_id=....&redirect_uri=....
这迫使我们通过Horizon前端的Web登录屏幕。 我们正在从智能手机开始登录流程,因此这并不是理想的选择,因为Horizon屏幕根本没有响应:(
[编辑]
该错误似乎是由于电子邮件地址中未编码的特殊字符造成的(我们有一个加号,因为gmail会忽略加号后的所有内容,从而使我们可以创建多个电子邮件地址,并仍通过真实的电子邮件地址接收它们:例如,用户名+test@gmail.com到达username@gmail.com)。
因此,我们的问题似乎已经消失了(或者全球固件实例上的最新Keyrock更新为我们解决了这个问题?)。 现在我们可以使用/ oauth2 / token?grant_type = password了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.