8000 Accessing private repos · Issue #703 · libgit2/objective-git · GitHub
[go: up one dir, main page]

Skip to content

Accessing private repos #703

Open
Open

Description

@schriftgestalt

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

Activity

  1. iain17 commented on Sep 14, 2020

    @iain17

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0