Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing private repos #703

Open
schriftgestalt opened this issue Mar 2, 2020 · 1 comment
Open

Accessing private repos #703

schriftgestalt opened this issue Mar 2, 2020 · 1 comment

Comments

@schriftgestalt
Copy link
Contributor

Is there a way to access private repos (e.g. clone them). How do I supply username and password.

@iain17
Copy link

iain17 commented Sep 14, 2020

You supply them using the CredentialProvider flags. For instance if you're doing a fetch set GTRepositoryRemoteOptionsCredentialProvider.

In Swift this could look like:

let auth = GTCredentialProvider { (type, url, username) -> GTCredential? in
                let cred = try? GTCredential(userName: username, publicKeyString: publicKey, privateKeyString: privateKey, passphrase: passphrase)
                return cred
 }
var options = [String : Any]()
options[GTRepositoryCloneOptionsCredentialProvider] = auth
options[GTRepositoryRemoteOptionsCredentialProvider] = auth
//Then call fetch or clone using these options:
GTRepository.clone(from: url, toWorkingDirectory: path, options: options)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants