20140510 twitter authentication by webauthentictionbroker in windows phone 8.1 with asyncoauth
DESCRIPTION
2014年5月10日 Windows Phone Arch in Tokyo #3 でのLT内容TRANSCRIPT
仕事
個人活動
http://bit.ly/metrotokyo4
http://tech.tanaka733.net
http://okazuki.hatenablog.com/entry/2014/04/21/003008
WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
protected async override void OnActivated(IActivatedEventArgs e){
//前半略var continuationEventArgs = e as IContinuationActivatedEventArgs;if (continuationEventArgs != null){
var page = rootFrame.Content as TwitterPage;if (page != null){
page.ContinueWebAuthentication(e as WebAuthenticationBrokerContinuationEventArgs);
}}
Window.Current.Activate();}
//パラメーターを生成var options = new List<KeyValuePair<string, string>>(capacity: 1)
{new KeyValuePair<string,string>("oauth_callback", callbackUri)
};
var headerParams = OAuthUtility.BuildBasicParameters("vPJVb79KWRIaTFAZ3ri5KY0cF","p1XJIHjnkvIF7zscQDOL1La4KpKfPNRTuvwIzSHDwtkv5YwtYe","https://api.twitter.com/oauth/access_token",System.Net.Http.HttpMethod.Post,new RequestToken(token, ""),options);
var header = headerParams.Select(p => p.Key + "=" + p.Value.Wrap("¥"")).ToString(",");
//AccessTokenを取得var client = new HttpClient();var request = new HttpRequestMessage(
HttpMethod.Post, "https://api.twitter.com/oauth/access_token")
{Content = new FormUrlEncodedContent
(new List<KeyValuePair<string, string>>(capacity: 1){
new KeyValuePair<string,string>("oauth_verifier", verifier)})};
request.Headers.Authorization = new AuthenticationHeaderValue("OAuth", header);var response = await client.SendAsync(request);
using
One More Thing…
http://www.microsoft.com/ja-jp/events/developer/default.aspx