Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# winform get access token facebook

protected override string QueryAccessToken(Uri returnUrl, string authorizationCode)
        {
            // Note: Facebook doesn't like us to url-encode the redirect_uri value
            var builder = new UriBuilder("https://graph.facebook.com/oauth/access_token");
            builder.AppendQueryArgument("client_id", this.appId);
            builder.AppendQueryArgument("redirect_uri", NormalizeHexEncoding(returnUrl.GetLeftPart(UriPartial.Path)));
            builder.AppendQueryArgument("client_secret", this.appSecret);
            builder.AppendQueryArgument("code", authorizationCode);

            using (WebClient client = new WebClient())
            {
                //Get Accsess  Token
                string data = client.DownloadString(builder.Uri);
                if (string.IsNullOrEmpty(data))
                {
                    return null;
                }

                var parsedQueryString = HttpUtility.ParseQueryString(data);
                return parsedQueryString["access_token"];
            }
        }
 private static string NormalizeHexEncoding(string url)
        {
            var chars = url.ToCharArray();
            for (int i = 0; i < chars.Length - 2; i++)
            {
                if (chars[i] == '%')
                {
                    chars[i + 1] = char.ToUpperInvariant(chars[i + 1]);
                    chars[i + 2] = char.ToUpperInvariant(chars[i + 2]);
                    i += 2;
                }
            }
            return new string(chars);
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: print bitmap company logo c sharp 
Csharp :: Unity Scene Load by BuildIndex 
Csharp :: pass viewbag selectlistitem to razor 
Csharp :: List of border roleplays roblox 
Csharp :: constant interpolated string 
Csharp :: mvc form name 
Csharp :: dapper extension 
Csharp :: how to hide tree level button when no record found for devexpress child grid view in Winform c# 
Csharp :: Get single listView SelectedItem 
Csharp :: close an open form when you open it again c# 
Csharp :: how to input message ox in c# 
Csharp :: how to add extra window to wpf 
Csharp :: c# string interpolation float format 
Csharp :: C# milisecond to h m s 
Csharp :: mono cast 
Csharp :: c# entity framework order by array 
Csharp :: get appsetting.json config .net 
Csharp :: Event that fires during DataGridViewComboBoxColumn SelectedIndexChanged 
Csharp :: how to instantiate particle system with a particular rotation 
Csharp :: ${1##*[! ]} 
Csharp :: csv to dataset c# 
Csharp :: skrivetækning 
Csharp :: duplicate global system runtime versioning targetframeworkattribute 
Csharp :: Xamarin Forms iOS Picker done 
Csharp :: c# silent execute exe 
Csharp :: dictionary and generic class c# 
Csharp :: c# use readonly array as method default 
Csharp :: c# dictionary key set 
Csharp :: how to start commvault services on linux 
Csharp :: c# linq unique by property 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =