Making an API call in Python with an API that requires a bearer token -


looking integrating json api call python program.

i looking integrate following api python .py program allow called , response printed: https://xforce-api.mybluemix.net:443/ipr/8.8.8.8

the api guidance states bearer token must generated allow calls api, have done successfully. unsure of syntax include token bearer token authentication in python api request.

i can complete above request using curl token included. have tried "urllib" , "requests" routes no avail.

full api details @ link: https://xforce-api.mybluemix.net/doc/#!/ip_reputation/ipr_ip_get

it means expects key in header data

import requests endpoint = ".../api/ip" data = {"ip":"1.1.2.3"} headers = {"authorization":"bearer myreallylongtokenigot"}  print requests.post(endpoint,data=data,headers=headers).json() 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -