Error 401: Unauthorized

I have been trying to copy and use code snippets from the Try It Out page such as get_look(), but when I try it I get an ‘Unauthorized’ error pretty much every time.

In a cell above the one pictured I connect to the API using my Client ID and Client Secret, which appears to work.

How should I go about making sure that my requests are authorized? Authorizing in the one place does not seem to authorize my requests elsewhere.

I’m not a huge Jupyter whiz, do things defined in previous cells carry down to the next cell? It seems like despite authenticating in one cell, if you try to make an API call in the next one it doesn’t work. This might be something Jupyter-y to figure out like “Persisting variables across cells” or something— Someone more familiar might be able to shed more light!

Hi @Jake_Wellins,

To Izzy’s point, as far as I know variables do persist between cells in a Jupyter notebook.

I haven’t really used the API but in your first picture you’re calling lookerapi.LookApi() with no arguments.

In the second pic you have looker.UserApi(client) and the client variable has the auth credentials. So maybe you need to pass client in the same way: LookAPI(client).

Also noticed in the two pics and the snippets I’ve included you have both looker and lookerapi - maybe these should be the same?

Thanks for that Simon that helps!

1 Like