20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth
-
Upload
- -
Category
Technology
-
view
651 -
download
1
description
Transcript of 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth
![Page 1: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/1.jpg)
![Page 2: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/2.jpg)
仕事
個人活動
http://bit.ly/metrotokyo4
http://tech.tanaka733.net
![Page 3: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/3.jpg)
![Page 4: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/4.jpg)
![Page 5: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/5.jpg)
![Page 6: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/6.jpg)
![Page 7: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/7.jpg)
![Page 8: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/8.jpg)
![Page 9: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/9.jpg)
http://okazuki.hatenablog.com/entry/2014/04/21/003008
![Page 10: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/10.jpg)
WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
![Page 11: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/11.jpg)
![Page 12: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/12.jpg)
![Page 13: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/13.jpg)
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();}
![Page 14: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/14.jpg)
//パラメーターを生成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(",");
![Page 15: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/15.jpg)
//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);
![Page 16: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/16.jpg)
![Page 17: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/17.jpg)
using
![Page 18: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/18.jpg)
One More Thing…
![Page 19: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/19.jpg)
http://www.microsoft.com/ja-jp/events/developer/default.aspx
![Page 20: 20140510 Twitter Authentication by WebAuthentictionBroker in Windows Phone 8.1 with AsyncOAuth](https://reader036.fdocument.pub/reader036/viewer/2022081404/55878e84d8b42a365d8b466f/html5/thumbnails/20.jpg)