Windows Live ID Delegated Authentication SDK
承認要求URLの作成には,
SDKに含まれるコードをWebサイトプロジェクトに追加しておきましょう。ソリューションエクスプローラからWebサイトを右クリックし,
SDKのファイルは
承認要求URLの提示
Webページに承認要求ページへのリンクを表示できるようコーディングしてみましょう。
承認要求URLのパラメータ作成に必要な情報をweb.
<appSettings>
<add key="wll_appid" value="Application ID/">
<add key="wll_secret" value="Secret Key"/>
<add key="wll_securityalgorithm" value="wsignin1.0"/>
<add key="wll_returnurl"
value="http://example.jp/WebSite/delauth-handler.aspx"/>
<add key="wll_policyurl"
value="http:// example.jp/WebSite/Policy.aspx"/>
<add key="wll_consenturl"
value="https://developer.mesh-ctp.com/web/apps/appconsent.aspx"/>
<add key="wll_appurl" value="Mesh/Applications/(ID)"/>
</appSettings>
設定のkeyとvalueは以下の通りです。Azure Services Developer PortalのプロジェクトSummaryページから必要な部分をコピーします。
Key | Value |
---|---|
wll_ |
Application ID |
wll_ |
Secret Key |
wll_ |
セキュリティアルゴリズム。 |
wll_ |
Return URL |
wll_ |
プライバシーポリシーURL |
wll_ |
承認要求URL |
wll_ |
Mesh上のWebサイトを表す相対URL |
Default.
<form id="form1" runat="server">
<div>
<span id="linkConsent" runat="server"><a href="<%=ConsentUrl%>">アクセス許可の設定</a></span>
</div>
</form>
Default.
Imports System.Web.Configuration
Imports Microsoft.LiveFX.Client
Imports Microsoft.LiveFX.ResourceModel
Imports WindowsLive
Partial Class _Default
Inherits System.Web.UI.Page
' 承認要求ページのURL
Public ConsentUrl As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' オファーとアクション
Const offers As String = "LiveMeshFolder.Full,Profiles.Read,Contacts.Write,News.Full"
' WindowsLiveLogin インスタンス生成 True 指定で Web.config の値を使用
Dim login = New WindowsLiveLogin(True)
' 承認要求 URL の作成
Me.ConsentUrl = login.GetConsentUrl(offers).Replace("Delegation.aspx", ) & _
"&appUrl=" & HttpUtility.UrlEncode(WebConfigurationManager.AppSettings("wll_appurl"))
End Sub
End Class
Windows Live ID Delegated Authentication SDKにあるWindowsLiveLoginクラスのGetConsentUrlメソッドを使用するとweb.
ここまで記述したら一度デバッグ実行してみましょう。ページ上のリンク
今回はここまでです。次回,