diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2011-06-21 20:51:34 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2011-06-21 20:51:34 -0700 |
commit | c1edc04e74e668425cd4b880b110011775395bd9 (patch) | |
tree | 47786fa6496f5a4dd6355a38545f051784649091 /samples/OAuthClient/SampleWcf2Javascript.js | |
parent | f6581ea68f421395bba0b3c2f7d72708cf72979c (diff) | |
download | DotNetOpenAuth-c1edc04e74e668425cd4b880b110011775395bd9.zip DotNetOpenAuth-c1edc04e74e668425cd4b880b110011775395bd9.tar.gz DotNetOpenAuth-c1edc04e74e668425cd4b880b110011775395bd9.tar.bz2 |
Finished implicit grant sample. Yay.
Diffstat (limited to 'samples/OAuthClient/SampleWcf2Javascript.js')
-rw-r--r-- | samples/OAuthClient/SampleWcf2Javascript.js | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/samples/OAuthClient/SampleWcf2Javascript.js b/samples/OAuthClient/SampleWcf2Javascript.js index 9eb945e..df72938 100644 --- a/samples/OAuthClient/SampleWcf2Javascript.js +++ b/samples/OAuthClient/SampleWcf2Javascript.js @@ -58,6 +58,20 @@ $(document).ready(function () { }); $(document).ready(function () { + $.support.cors = true; // force cross-site scripting (as of jQuery 1.5) + function serviceCall(operation, accessToken, label) { + label.text('fetching...'); + $.ajax({ + url: "http://localhost:65169" + encodeURI(operation), + headers: { + "Authorization": "Bearer " + accessToken + }, + cache: false, + success: function (data, textStatus, jqXHR) { label.text(data.toString()); }, + error: function (jqXHR, textStatus, errorThrown) { label.text(textStatus + ": " + errorThrown); } + }); + }; + var fragmentIndex = document.location.href.indexOf('#'); if (fragmentIndex > 0) { var fragment = document.location.href.substring(fragmentIndex + 1); @@ -69,13 +83,19 @@ $(document).ready(function () { authorizationLabel.text('Authorization received! ' + suffix); var scopes = args['scope'].split(' '); - for (var scope in scopes) { - var button = $('input[operation="' + scopes[scope] + '"]')[0]; - button.disabled = false; - - var checkbox = $('input[value="' + scopes[scope] + '"]')[0]; + for (var scopeIndex in scopes) { + var scope = scopes[scopeIndex]; + var button = $('input[operation="' + scope + '"]'); + button[0].disabled = false; + button.click((function (value) { + return function () { + var label = $('span[operation="' + value + '"]'); + serviceCall(value, args['access_token'], label); + }; + })(scope)); + var checkbox = $('input[value="' + scope + '"]')[0]; checkbox.checked = true; - } + }; } } });
\ No newline at end of file |