> For the complete documentation index, see [llms.txt](https://offerslook-api.gitbook.io/api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://offerslook-api.gitbook.io/api-documentation/demo_code/http_basic_authentication_python.md).

# Http Basic authentication python

## python example 1:

```python
import requests
def basic_auth_example(network_name,api_key,offer_s,update_data):
    api_url = "http://%s:%s@%s.api.offerslook.com/v1/offers/%s" %(network_name,api_key,network_name,offer_s)
    data = update_data 
    querystring = ''
    req = requests.request("PUT",api_url,data=update_data,headers={'content-type':"application/json",'cache-control': "no-cache",'postman-token': "4d5c83b4-a338-19a5-03d0-d5a81524bfac"},params=querystring)
    response = req.text
    print response

offer_id = 10001
network_name = "demo"
api_key = "8cca20a07a24a7e425835221def4066a"
update_data = '{"offer":{"lead_traffic":1}}'    #Enable offer sync click
basic_auth_example(network_name,api_key,offer_id,update_data)
```

## python example 2:

```python
import base64,json,urllib2
def basic_auth_example2(network_name,api_key,offer_s,update_data):
    api_url = "http://%s.api.offerslook.com/v1/offers/%s" %(network_name,offer_s)
    base64string = base64.encodestring('%s:%s' %(network_name,api_key))[:-1]
    authheader =  "Basic %s" %base64string
    req = urllib2.Request(api_url,data=update_data,headers={'content-type':'application/json','Authorization':authheader});
    req.get_method = lambda:'PUT';
    response = urllib2.urlopen(req);
    print response.read();

offer_id = 10001
network_name = "demo"
apikey = "8cca20a07a24a7e425835221def4066a"
dict_data = {"offer": {"lead_traffic": 1}};
data = json.dumps(dict_data);
basic_auth_example2(network_name,apikey,offer_id,data)
```
