Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2872ed8

Browse files
author
Steven Kirk
committed
Continue listening for oauth response.
Don't error our on first non-matching response, keep listening until the correct response is receved or the operation is cancelled (i.e. the login dialog is closed).
1 parent 032cc0f commit 2872ed8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/GitHub.App/Services/OAuthCallbackListener.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,21 @@ public async Task<string> Listen(string id, CancellationToken cancel)
4646

4747
try
4848
{
49-
var complete = new TaskCompletionSource<HttpListenerContext>();
50-
5149
using (cancel.Register(httpListener.Stop))
5250
{
53-
var context = await httpListener.GetContextAsync();
54-
var foo = context.Request;
55-
var queryParts = HttpUtility.ParseQueryString(context.Request.Url.Query);
56-
57-
if (queryParts["state"] == id)
51+
while (true)
5852
{
59-
context.Response.Close();
60-
return queryParts["code"];
53+
var context = await httpListener.GetContextAsync();
54+
var foo = context.Request;
55+
var queryParts = HttpUtility.ParseQueryString(context.Request.Url.Query);
56+
57+
if (queryParts["state"] == id)
58+
{
59+
context.Response.Close();
60+
return queryParts["code"];
61+
}
6162
}
6263
}
63-
64-
throw new WebException("The login returned an unexpected response.");
6564
}
6665
finally
6766
{

0 commit comments

Comments
 (0)