cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to get a git access token on the databricks notebook.

674491
New Contributor II

I set my git access token with folloing the page.

Get a Git access token & connect a remote repo to Databricks | Databricks on AWS

I would like to get that git token on my databricks python notebook.

Is it possible? Or, should I set same or another git access token on databricks secret cli if I use it on python notebook?

2 REPLIES 2

Anonymous
Not applicable

@takeshi.kida​ :

Yes, it is possible to access your Git access token on a Databricks notebook. You can use the Databricks secrets API to securely store and retrieve your Git access token in your notebook.

Here are the general steps to follow:

  1. Set up a Databricks secret with your Git access token using the Databricks CLI or the Databricks UI.
  2. In your notebook, use the Databricks secrets API to retrieve your Git access token. You can do this by calling the dbutils.secrets.get function, passing in the name of your secret as the argument. For example, if you named your secret git-access-token, you can retrieve it using the following code:
token = dbutils.secrets.get(scope="my-secrets", key="git-access-token")

3 Use the retrieved Git access token in your notebook code as needed.

Note that you can also use the GIT_ASKPASS environment variable to specify your Git access token when running Git commands in your notebook. This can be useful if you don't want to retrieve the access token explicitly in your code. In this case, you can set the GIT_ASKPASS environment variable to a script that retrieves the access token from a Databricks secret and prints it to standard output. You can then configure Git to use this script as the "askpass" program by setting the

core.askpass Git configuration option.

Anonymous
Not applicable

Hi @takeshi.kida​ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group