Skip to content

Instantly share code, notes, and snippets.

@brianly
Created January 19, 2013 18:55
Show Gist options
  • Save brianly/4574309 to your computer and use it in GitHub Desktop.
Save brianly/4574309 to your computer and use it in GitHub Desktop.
Stupid WinForms example showing how to Embed a browser control and handle Yammer OAuth.
// Add these to a form:
// * Web Browser
// * Button 1 (starts the process)
// * Button 2 (outputs the current URL)
// * TextBox 1 (logs actions)
// * TextBox 2 (for the token)
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.yammer.com/dialog/oauth?client_id=SFZc9HHFXK77keEFYdXphw&redirect_uri=http://brianlyttle.com/yammer/mshtml/redirect_uri&response_type=token");
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(webBrowser1.Url.ToString());
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
textBox1.Text += string.Format("Navigating: {0}{1}", e.Url, Environment.NewLine);
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
textBox1.Text += string.Format("Navigated: {0}{1}", e.Url, Environment.NewLine);
if (e.Url.Host == "brianlyttle.com")
{
textBox1.Text += ("Fragment: " + e.Url.Fragment);
textBox2.Text = e.Url.Fragment.Replace("#access_token=", "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment