public static IAsyncOperationWithProgress <Token, HttpProgress> FetchAsync(Uri callbackUri) { if (callbackUri == null) { throw new ArgumentNullException(nameof(callbackUri)); } var query = callbackUri.Query.Split(new[] { '?', '&', '=' }, StringSplitOptions.RemoveEmptyEntries); if (query.Length == 2) { return(MyHttpClient.PostJsonAsync <Token>(TokenUri, getData("authorization_code", query[1], null, null))); } else if (query.Length == 4) { var ci = Array.IndexOf(query, "code") + 1; var si = Array.IndexOf(query, "state") + 1; if (ci > 0 && si > 0) { return(MyHttpClient.PostJsonAsync <Token>(TokenUri, getData("authorization_code", query[ci], query[si], null))); } } throw new ArgumentException("回调参数错误"); }
public IAsyncActionWithProgress <HttpProgress> RefershAsync() { return(MyHttpClient.PostJsonAsync(TokenUri, getData("refresh_token", null, null, this.RefreshToken), this)); }