objective-git icon indicating copy to clipboard operation
objective-git copied to clipboard

Accessing private repos

Open schriftgestalt opened this issue 5 years ago • 1 comments

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

schriftgestalt avatar Mar 02 '20 10:03 schriftgestalt

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)

iain17 avatar Sep 14 '20 07:09 iain17