Impossible to push to Azure repository using Person Access Token
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- azure, csharp, git
- Ambito
- authentication, devtools
Direzione di ricerca
Inizia esaminando PushOptions e confrontando la configurazione disponibile con FetchOptions, quindi leggi la pull request #2011 e l’esempio della wiki di git-push. Il lavoro è completato quando un push verso un repository Azure può passare il PAT come intestazione di autorizzazione personalizzata senza errori di ripetizione dell’autenticazione; aggiungi o aggiorna i test pertinenti se il sottosistema esistente li fornisce.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
My problem is described perfectly here, but I don't think the solution is the correct one, since that would use the credentials stored on the computer as far as I'm aware.
When making git requests to an azure repository with a PAT, it is expected to be passed along as a custom header. (see documentation).
This is possible when doing a Clone operation, since CloneOptions contains FetchOptions, which allows us to set custom headers.
So a clone is perfectly possible as follows:
string encodedToken = Convert.ToBase64String(Encoding.UTF8.GetBytes($":{credentials.PersonalAccessToken}"));
var fetchOptions = new FetchOptions
{
CustomHeaders = new[] {
$"Authorization: Basic {encodedToken}"
}
};
var options = new CloneOptions
{
CredentialsProvider = (url, usernameFromUrl, types) =>
new UsernamePasswordCredentials()
{
Username = credentials.UserName,
Password = credentials.PersonalAccessToken
},
FetchOptions = fetchOptions,
BranchName = branchName,
Checkout = true,
OnCheckoutProgress = (path, completedSteps, totalSteps) =>
Logger.LogInformation("Clone progress {completed} / {total}", completedSteps, totalSteps),
RepositoryOperationCompleted = (context) =>
Logger.LogInformation("Clone completed"),
};
Repository.Clone(Remote, WorkingDirectory, options);
However, when trying to push to this same repository, PushOptions does not expose something similar to include the PAT as header, even though it is stored in the internal data structure since https://github.com/libgit2/libgit2sharp/pull/1233 .
Using the provided example from the wiki
I get the following error:
Unhandled exception: too many redirects or authentication replays | LibGit2Sharp.LibGit2SharpException | too many redirects or authentication replays
Which is the exact same error I was getting when trying to clone without the added custom header.
As far as I can see, there is a PR open that would fix this, but it is not yet merged in: https://github.com/libgit2/libgit2sharp/pull/2011
- Lingua principale
- C#
- Stelle
- 3.5k
- Fork
- 925
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di libgit2/libgit2sharp
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
libgit2/libgit2sharp#2193 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
libgit2/libgit2sharp#2192 · 1 commento ·
-
Website is down Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
libgit2/libgit2sharp#2191 · 2 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
libgit2/libgit2sharp#2189 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
libgit2/libgit2sharp#2187 · 2 commenti ·
Tutte le issue di libgit2/libgit2sharp
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
sillsdev/languageforge-lexbox#2665 ·
-
C: Syntax
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
bug documentation frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
azurenoops/spin_agent#975 ·
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SubtitleEdit/subtitleedit#15108 · 1 commento ·