Details
-
Type: extRequest
-
Status: Closed
-
Priority: Major
-
Resolution: Done
-
Fix Version/s: 2021
-
Component/s: FIWARE-TECH-HELP
-
Labels:None
-
HD-Chapter:Data
-
HD-Enabler:Cosmos
Description
Hi, please find hereafter a snipped python code to use OAuth2 on Cosmos,
but the services always replies 401, even if token is used.
Username and password for getting the token is the ones of a FIWARE LAB
user.
May you help us?
Thanks in advance for your help,
P.
------------------------------------
import requests
def get_oauth_token():
OAUTH_SERVER = "https://130.206.80.46:13000/cosmos-auth/v1/token"
OAUTH_CONTENT = "grant_type=password&username=XXX&password=XXX"
req_headers =
{'Content-Type': 'application/x-www-form-urlencoded'} r = requests.post(OAUTH_SERVER, data=OAUTH_CONTENT,
headers=req_headers, verify=False)
res = r.json()
return res['access_token']
if _name_ == "_main_":
headers = None
t = get_oauth_token()
if not headers:
headers = {}
headers['X-Auth-Token'] = t
print headers
TEST_GET = "http://130.206.80.46:14000/webhdfs/v1/user/XXXXXX.txt"
TEST_GET_PARAMS = "op=getfilestatus&user.name=XXXX"
response = requests.get(TEST_GET, data=TEST_GET_PARAMS,
headers=headers)
print response
--------------
Pasquale Andriani
Direzione Ricerca e Innovazione - Research & Development Lab
pasquale.andriani@eng.it
Engineering Ingegneria Informatica spa
Via Riccardo Morandi, 32 - 00148 Roma
Tel. +39-06.87594138
Mob. +39 3924698746
Fax. +39-06.83074408
www.eng.it
_______________________________________________
Fiware-lab-help mailing list
Fiware-lab-help@lists.fi-ware.org
https://lists.fi-ware.org/listinfo/fiware-lab-help
Activity
Field | Original Value | New Value |
---|---|---|
Component/s | FIWARE-TECH-HELP [ 10278 ] |
Assignee | Francisco Romero [ frb ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Answered [ 10104 ] |
Summary | [Fiware-lab-help] OAuth2 authentication on COSMOS - token returned but next request replies 401 | FIWARE.Request.Lab.Data.BigData-Analysis. |
Summary | FIWARE.Request.Lab.Data.BigData-Analysis. | FIWARE.Request.Lab.Data.BigData-Analysis.401EvenWithAuthToken |
Resolution | Done [ 10000 ] | |
Status | Answered [ 10104 ] | Closed [ 6 ] |
Summary | FIWARE.Request.Lab.Data.BigData-Analysis.401EvenWithAuthToken | FIWARE.Request.Tech.Data.BigData-Analysis.401EvenWithAuthToken |
HD-Enabler | Cosmos [ 10872 ] | |
HD-Chapter | Data [ 10838 ] |
Fix Version/s | 2021 [ 12600 ] |