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 at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.fiware.org/private/fiware-lab-help/attachments/20150714/5aff940c/attachment.html>
You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy Cookies policy