avatarParth Dasawant

Summary

Google Colab introduces a new feature called Secrets, which simplifies the process of managing and protecting sensitive information in the platform.

Abstract

Google Colab has launched a new feature called Secrets, which allows users to securely store and manage sensitive information such as environment variables, file paths, or keys. This feature ensures privacy, as the values are accessible only to the user and selected notebooks. Sharing a notebook won't expose the stored secrets, as they remain confidential. To use Secrets, users can open Google Colab, go to Secrets, enter the Name and Value of the secret, and toggle Notebook access. The secret value can be accessed in the notebook using the given code with the name of the secret. Secrets can be used across multiple notebooks, and the value can be changed by toggling the Visibility icon in the Action tab.

Bullet points

  • Google Colab introduces a new feature called Secrets to simplify the management and protection of sensitive information.
  • Secrets allows users to securely store environment variables, file paths, or keys.
  • Values are accessible only to the user and selected notebooks, ensuring privacy.
  • Sharing a notebook won't expose the stored secrets.
  • To use Secrets, users can open Google Colab, go to Secrets, enter the Name and Value of the secret, and toggle Notebook access.
  • The secret value can be accessed in the notebook using the given code with the name of the secret.
  • The secret value received from userdata.get('<secretName>') is of string type. If the value is numeric, it needs to be converted into a suitable numeric type.
  • The value can be changed by toggling the Visibility icon in the Action tab.
  • Once added, the secret can be accessible for all notebooks.
  • To use it in a different notebook, users just have to grant access to that particular notebook by toggling the Notebook access.

How to use Secrets in Google Colab

A new way to hide, access & manage the secrets in the Colab

Keeping sensitive information like API keys and user-related secrets secure on Google Colab used to be a repetitive and complex ordeal. But now, a new feature is set to change the game.

In this article, we’ll explore newly launched Secrets in Colab, making it easy to protect your data without dealing with complicated setups. Join us as we uncover this exciting addition and learn how to enhance your project’s security effortlessly.

Key Features

  • Simplify code configuration by securely storing environment variables, file paths, or keys.
  • Ensure privacy with values accessible only to you and the selected notebooks.
  • Remember, secret names cannot include spaces.
  • Sharing a notebook won’t expose your stored secrets; they remain confidential.
Secrets feature in Colab

How to use

  • Open Google Colab, and go to Secrets.
  • Enter the Name and Value of the secret. Even though the Value can be changed the Name couldn’t change.
  • Toggle Notebook access.
  • Finally, for using it in the notebook, use the given code with the name of your secret instead of .
from google.colab import userdata
userdata.get('<secretName>')
  • The secret value received from userdata.get('<secretName>') is of string type. Therefore, if your value is numeric then you have to convert it into a suitable numeric type.
  • For changing the value, the toggle Show secret "<secretName>" value option is shown by the Visibility icon in the Action tab.
Once the Value is visible then you can change the Value.
  • Once added, the secret can be accessible for all notebooks.
Toggle: The one-stop shop for your ‘on-off’ moments!
  • To use it in a different notebook, you just have to grant access to that particular notebook by toggling the Notebook access.
Google Colaboratory

In conclusion, Google Colab’s Secrets feature offers a straightforward and secure way to protect your sensitive information. It keeps your projects safe and sound, even when you share your notebooks.

Thanks for reading. Keep it Simple, Make it Great!

Google Colab
Secrets
Python
Security
New Features
Recommended from ReadMedium