1
votes

I am following the Fiware context broker introduction to get a token: https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Publish/Subscribe_Broker_-_Orion_Context_Broker_-_Quick_Start_for_Programmers

I got the script:

$ wget --no-check-certificate https://raw.githubusercontent.com/fgalan/oauth2-example-orion-client/master/token_script.sh

and I run it as explained:

$ bash token_script.sh

username: [my valid fiware email account]

password: [my valid fiware account password]

But it does not returns any access token. Actually, it does not return anything, no organization, no id, no name.... (I have an organization)

I am running the script in a Fiware cloud instance (Ubuntu 14.04)

UPDATED:

here the verbose from running the script as requested:

root@ubuntu:~# bash -x token_script.sh + echo ''

+ read -p 'Username: ' USER
Username: vicens@datalook.io
+ read -s -p 'Password: ' PASSWORD
Password: + echo ''

++ curl -s -d '{"auth": {"passwordCredentials":                 {"username":"vicens@datalook.io", "password”:”xxxxxxxx”}}}’ '-HContent-   type: application/json' http://cloud.lab.fi-ware.org:4730/v2.0/tokens
+ RESP=
++ sed 's/{"access":{"token":{.*"id":"\(.*\)"},"user.*$/\1/g'
++ echo
+ TOKEN=
+ echo -e '\nAccess Token: '

Access Token: 
++ curl -s '-Hx-auth-token: ' http://cloud.lab.fi-   ware.org:4730/v2.0/tenants
+ ORGS=
+ echo -e '\nOrganizations: '

Organizations: 
+ set ORGS2=
+ awk -v k=text '{printf("%-32s %s \n", "ID", "Name"); n=split($0,a,"   [{}]"); for (i=1; i<=n; i++) {m=split(a[i], b, "[,:\"]"); if (m>=15) printf("%-32s %s \n",  b[9], b[15])}}'
+ echo
ID                               Name 
+ echo ''

+ read -p 'Select an organization from the list above (ID): ' ORG
Select an organization from the list above (ID): 
+ BODY='{"auth": {"token":{"id": ""}, "tenantId": ""}}'
++ curl -s -X POST -H 'Content-Type: application/json' -d '{"auth":    {"token":{"id": ""}, "tenantId": ""}}' http://cloud.lab.fi-ware.org:4730/v2.0/tokens
+ RESP1=
++ sed 's/{"access":{"token":{.*"id":"\(.*\)","tenant.*$/\1/g'
++ echo
+ TOKEN=
+ echo -e '\nToken: '

Token: 
+ echo ''

Cheers, Vicens.

1
I have just executed the same script and everything seems to be ok on my sidie. In oder to get more information about your problem, could you execute the script in "verbose" mode with bash -x token_script.sh, next update your question to include the exact output you get, please? Thanks!fgalan
Before posting your output, take care of not publish your FIWARE Lab password in cleartext (replace it by **** in the output when editing your post).fgalan
Added the result of running the script in verbose mode, thanks and sorry for the delay in the answer.Vicens Fayos

1 Answers

0
votes

I have done the same test. In may case:

  • When email and/or password are wrong, I get the following RESP line:

    + RESP='User credentials not authorized'

  • When I introduce the right email and password, I get the follwing RESP line:

    + RESP='{"access":{"token":{"expires":"2015-07-09T15:16:07Z","id":"IxxxxWBY0uTT1jjrKfTvq9KKBl_GiCoaNMExhM6PX1bH-ZeeoCzCVkA0uzWLZ8LTKE4MG6VxARAY1MEaYqr2Rg"},"user":{"username":"fermin","roles_links":[],"id":"fermin","name":"Fermin"}}}'

Thus, I'm not able to reproduce the problem and get the empty RESP line (+ RESP=) you get.

Maybe it was due to some network problem, some temporal unavailability of the security components or any other glitch of some kind.