Пример #1
0
        /// <summary>
        /// Complete authentication with a manually entered string.
        /// </summary>
        /// <param name="verifierKey">The string that user entered manually.</param>
        /// <param name="callback">A function to call when the user has been added.</param>
        public async Task <User> CompleteAuth(string verifierKey)
        {
            var result = await ReadabilityClient.GetAccessToken(verifierKey);

            if (result == true)
            {
                return(await GetCurrentUser());
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Complete the authentication with a URI.
        /// </summary>
        /// <param name="uri">The URI that finished the auth process. We will parse this for the verification key.</param>
        /// <param name="callback">A function to call when the user has been added.</param>
        public async Task <User> CompleteAuth(Uri uri)
        {
            if (uri.OriginalString.Contains("oauth_callback"))
            {
                var decodedUri = System.Net.HttpUtility.UrlDecode(uri.OriginalString);
                var arguments  = decodedUri.Split('?');
                if (arguments.Length < 1)
                {
                    return(null);
                }

                // 2 is the second part of the url (after the second question mark)
                var verifierKey = Utilities.GetQueryParameter(arguments[2], "oauth_verifier");
                await ReadabilityClient.GetAccessToken(verifierKey);

                return(await GetCurrentUser());
            }
            return(null);
        }