Fetch Dashboard Data and ID with Python API

I’m trying to download a dashboard’s data through Python.

Using Requests, I can generate an access token.

import requestsdef log_me_in(id, secret, base_url):   payload = {'client_id': id, 'client_secret': secret}   url = base_url + '/login'   r = requests.post(url, data=payload)   # check for successful auth   if r.status_code == 200:      token = r.json()['access_token']      return token   else:      print('Authentication failed')id = "********************"secret = "****************"base_url = "https://mycompany.looker.com:19999/api/3.1"token = log_me_in(id, secret, base_url)print(token)

OUT


What code can I use to fetch my dashboard?

And how can I list my accessible dashboards and their dashboard IDs?

We would generally recommend using the Python SDK because it handles the token aspect of authentication, but you could do something similar to this:

This is for getting a Look, but the same structure can be applied to fetch a dashboard.

import requests 
ID = 'CLIENTIDGOESHERE'
SECRET = 'SECRETGOESHERE'
PARAMS = {'client_id':ID, 
            'client_secret': SECRET} 
URL = "https://self-signed.looker.com:19999/api/3.1/login"
r = requests.post(url = URL, params = PARAMS, verify=False) 
data = r.json()
token = data['access_token']
print(token)
headers = {'Authorization': "Bearer " + token}
print(headers)
look_url = "https://self-signed.looker.com:19999/api/3.1/looks/12"
look = requests.get(look_url, headers=headers,verify=False)
json = look.json()