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

CredentialsHandler #50

Open
Proxx opened this issue Aug 20, 2015 · 1 comment
Open

CredentialsHandler #50

Proxx opened this issue Aug 20, 2015 · 1 comment

Comments

@Proxx
Copy link

Proxx commented Aug 20, 2015

Hi there,

I did manage to create some functions to mimic the GIT functions.
but i cannot write functions that need authentication.

i do not know how to translate the (url, usernameFromUrl, types) => part of the CredentialsHandler to powershell

    options.CredentialsProvider = new CredentialsHandler(
        (url, usernameFromUrl, types) =>
            new UsernamePasswordCredentials()
            {
                Username = USERNAME,
                Password = PASSWORD
            });
[LibGit2Sharp.UsernamePasswordCredentials] $UserCred = New-Object LibGit2Sharp.UsernamePasswordCredentials
$Credentials.UserName = $Username
$Credentials.Password = $Password
PS U:\> [LibGit2Sharp.Handlers.CredentialsHandler]::new

OverloadDefinitions                                                                       
-------------------                                                                       
LibGit2Sharp.Handlers.CredentialsHandler new(System.Object object, System.IntPtr method)  

so the main question is how to create a "CredentialsHandler"

@dahlbyk
Copy link

dahlbyk commented Aug 25, 2015

CredentialsHandler is just a delegate. Have you tried something like this?

options.CredentialsProvider = {
  param($url, $usernameFromUrl, $types)
  # Inspect params if you want
  $UserCred = New-Object LibGit2Sharp.UsernamePasswordCredentials
  $UserCred.UserName = $Username
  $UserCred.Password = $Password
  return $UserCred 
}

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