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

GitLab Token issue on ConvertTo-SecureString #87

Closed
NealWalters opened this issue Jan 24, 2019 · 3 comments
Closed

GitLab Token issue on ConvertTo-SecureString #87

NealWalters opened this issue Jan 24, 2019 · 3 comments

Comments

@NealWalters
Copy link

NealWalters commented Jan 24, 2019

Is this module compatible with GitLab?
I have a token that was working with PSGitLab, but I haven't found a clone feature on that module.

I have modified the token, but it looks roughly like the one below:

$secureString = ('abCdEf1gHIJKL2m_123A' | ConvertTo-SecureString)

Results in this error:

ConvertTo-SecureString : Input string was not in a correct format.
At line:1 char:43

  • $secureString = ('abCdEf1gHIJKL2m_123A' | ConvertTo-SecureString)
  •                                       ~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [ConvertTo-SecureString], FormatException
    • FullyQualifiedErrorId : System.FormatException,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand

Thanks,
Neal Walters

@HowardWolosky
Copy link
Member

HowardWolosky commented Jan 24, 2019

Hi Neal,

The GitLab and GitHub API's are not quite the same, so this module would not work with it (at least not without some decent amount of modification).

As an aside, you can't create a SecureString that way. You don't need a SecureString to work with this module since it directly works with a PSCredential object (refer to the [Configuration] (https://github.com/PowerShell/PowerShellForGitHub#configuration) documentation) (and a PSCredential uses SecureString behind the scenes).

If you really wanted to get a SecureString for some other purpose, you'd get it by doing the following:

$cred = Get-Credential
# Enter anything in for username and then enter in your token as the password
$cred.Password # this will be the SecureString
$cred.Password | ConvertFrom-SecureString # this will give you an ASCII representation of the secure string which you can then convert back to a secure string using your previously referenced ConvertTo-SecureString

@NealWalters
Copy link
Author

Thanks, I'm playing with PSGitLab as well, but can't find a clone/commit function with them. Seems like standard GitHub command line works with GitLab, so I thought maybe the interface was close enough.

By the way, I got that "SecureString" code by doing the following:

Get-Help Set-GitHubAuthentication -ShowWindow
It's Example #2. So I think it's code you provided in your docs, am I wrong?

Neal

@HowardWolosky
Copy link
Member

HowardWolosky commented Jan 24, 2019

Thanks for pointing out the confusing example. That should have been more clear that <Your Access Token> should have already been in a secure string form. I'll get that example cleaned-up a bit.

As for your core concern, cloning and committing should be done directly through git itself. Where a module like this or PSGitLab come into play is how you further manage a project (like controlling issues, creating forks, managing teams/orgs, etc...). Cloning and committing are core git commands that git.exe should be able to handle on any repo, regardless of where it's hosted (GitHub, DevOps, GitLab, etc...).

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