Skip to content

Instantly share code, notes, and snippets.

@larsw
Created April 12, 2012 10:15
Show Gist options
  • Save larsw/2366271 to your computer and use it in GitHub Desktop.
Save larsw/2366271 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.8.18.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#clicker').click(function () {
$.ajax({
url: "https://kredinor-tfs.accesscontrol.windows.net/v2/metadata/IdentityProviders.js?protocol=wsfederation&realm=http%3a%2f%2flocalhost%3a81%2f&version=1.0&context=http%3a%2f%2flocalhost%3a81%2f",
dataType: "jsonp",
success: function (data, textStatus, jqXHR) {
$('<div id="identity-provider-content">' +
'<h2>Sign in using one of the following Identity Providers</h2>' +
'<div id="identity-providers"></div></div>').appendTo("#output");
for (var i in data) {
$(GetIdentityProviderTag(data[i], i)).appendTo("#identity-providers");
$("#button" + i + " button").data("signInUrl", data[i].LoginUrl);
}
$('button').button();
$('button').click(function () {
window.location = $.data(this, "signInUrl");
});
},
error: function (jqXHR, textStatus, errorThrown) {
console.log('error');
console.log(textStatus);
console.log(errorThrown);
}
});
return false;
}
);
});
function GetIdentityProviderTag(idp, index) {
return '<div class="identity-provider" id="button' + index + '"><button>' + idp.Name + ' </button></div>';
}
</script>
</head>
<body>
<button id="clicker">Click!</button>
<div id="output">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment