[英]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.