xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
541 stars 351 forks source link

Add CancellationToken parameter to RequestAccessTokenAsync #379

Open nickl-martin opened 5 years ago

nickl-martin commented 5 years ago

Xamarin.Auth Pull Request

Checklist

Changes proposed in this pull request:

Adds 2 overloaded methods of OAuth2Authenticator.RequestAccessTokenAsync that include a CancellationToken parameter. The cancellation token is used in the underlying HttpClient.PostAsync call. These new overloaded methods will throw a TaskCanceledException if the token is cancelled so they should be used inside a try/catch block. These are non-breaking changes to the API.

Example Usage:

try {
    using(var cts = new CancellationTokenSource()) {
        cts.CancelAfter(5000);
        var results = await authenticator.RequestAccessTokenAsync(queryValues, cts.Token);
        return results;
    }
} catch(TaskCanceledException) {
    Debug.WriteLine("RequestAccessToken timed out after 5 seconds.");
    return null;
}
dnfclas commented 5 years ago

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

:x: nickl-martin sign now
You have signed the CLA already but the status is still pending? Let us recheck it.

moljac commented 5 years ago

@nickl-martin CLA sign please...

nick-peters-luciani commented 5 years ago

I ended up transferring this fork this to my personal account. Do I need to make a new pull request in order to sign the CLA with this account?

moljac commented 5 years ago

There are 2 links (I gues for you)

I think you should visit those, sign the CLA and no new PR is needed.

OTOH I can add your code manually and close this PR.