a better task handling
This commit is contained in:
parent
49f5c1ab0a
commit
85cfd10544
1 changed files with 21 additions and 10 deletions
|
|
@ -380,6 +380,8 @@ public class YaOAuth2Authenticator : WebRedirectAuthenticator
|
||||||
}
|
}
|
||||||
|
|
||||||
var auth = req.GetResponseAsync().ContinueWith(task =>
|
var auth = req.GetResponseAsync().ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.IsCompleted)
|
||||||
{
|
{
|
||||||
var text = task.Result.GetResponseText();
|
var text = task.Result.GetResponseText();
|
||||||
req.Abort();
|
req.Abort();
|
||||||
|
|
@ -398,6 +400,15 @@ public class YaOAuth2Authenticator : WebRedirectAuthenticator
|
||||||
{
|
{
|
||||||
throw new AuthException("Expected access_token in access token response, but did not receive one.");
|
throw new AuthException("Expected access_token in access token response, but did not receive one.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (task.IsFaulted)
|
||||||
|
{
|
||||||
|
throw new AuthException("Unexpected fault");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new AuthException($"Ended: {task.Status}");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue