Facebook.FacebookClient.TryParseOAuthCallbackUrl C# (CSharp) Method

TryParseOAuthCallbackUrl() private method

private TryParseOAuthCallbackUrl ( Uri url, FacebookOAuthResult &facebookOAuthResult ) : bool
url Uri
facebookOAuthResult FacebookOAuthResult
return bool
        public virtual bool TryParseOAuthCallbackUrl(Uri url, out FacebookOAuthResult facebookOAuthResult)
        {
            facebookOAuthResult = null;

            try
            {
                facebookOAuthResult = ParseOAuthCallbackUrl(url);
                return true;
            }
            catch
            {
                return false;
            }
        }

Usage Example

        private void FBLogin_Navigated(object sender, NavigationEventArgs e)
        {
            // whenever the browser navigates to a new url, try parsing the url.
            // the url may be the result of OAuth 2.0 authentication.

            var fb = new FacebookClient();
            FacebookOAuthResult oauthResult;
            if (fb.TryParseOAuthCallbackUrl(e.Uri, out oauthResult))
            {
                // The url is the result of OAuth 2.0 authentication
                if (oauthResult.IsSuccess)
                {
                    var accesstoken = oauthResult.AccessToken;
                    FBLogin.IsEnabled = false;
                    accessToken = accesstoken;
                }
                else
                {
                    var errorDescription = oauthResult.ErrorDescription;
                    var errorReason = oauthResult.ErrorReason;
                }
            }
            else
            {
                // The url is NOT the result of OAuth 2.0 authentication.

            }
        }
All Usage Examples Of Facebook.FacebookClient::TryParseOAuthCallbackUrl