For example, if my current Colab instance is signed in as
Is it possible to get the name "myColab" in ipython?
What is the command to do this?
I want to do this because I may run two Colab, and they generate files, I want to tag these files with Colab account name, so I know which account generate these files.
By default, the backends are not authenticated for any particular user. But, if you've gone through through the gcloud auth
flow, you can retrieve the email address like so:
https://colab.research.google.com/drive/1VVWs_pcjjz2vg0H2Ti6-12FzcCojRF6a
The key snippet is:
import requests
gcloud_token = !gcloud auth print-access-token
gcloud_tokeninfo = requests.get('https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=' + gcloud_token[0]).json()
print(gcloud_tokeninfo['email'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With