Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have this small code in a python lambda that is trying to pull down a repo from bitbucket:

import git
def git_clone(username,password):
   new_dir = os.getcwd() + "/temp/"
   os.chdir(new_dir)
   GIT_URL = "https://{0}:{1}@bitbucket.org/test-project/test.git".format(username,password)
   git.Git(new_dir).clone(GIT_URL)

The git method accepts my username but does not accept my password. My password contains letters, numbers and special chars. i get this error:

URL using bad/illegal format or missing URL

Could this be a formatting issue?

Don't put the credentials in the URL, since that means they get written to disk. Use a credential helper. – bk2204 Nov 18, 2021 at 22:24

Here is a solution to your problem. I tested it and it works.

#!/usr/bin/env python
import os 
def git_clone(password, username):
    if password and username:
        url_string = r"git clone https://{}:{}@bitbucket.org/{}/test.git".format(username, password, username)
        os.system(url_string)
git_clone(username="<username>", password="<password>")

If this solves your problem, don't forget to accept and upvote it as the correct answer

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.