1 <?xml version="1.0" encoding="UTF-8" ?>
3 <ModulePrefs title="Demo OAuth Gadget">
6 <Request url="http://localhost:9090/oauth-provider/request_token" />
7 <Access url="http://localhost:9090/oauth-provider/access_token" />
8 <Authorization url="http://localhost:9090/oauth-provider/authorize?oauth_callback=http://localhost:8080/gadgets/oauthcallback" />
11 <Preload authz="oauth" href="http://localhost:9090/oauth-provider/echo" />
24 <div id="main" style="display: none">
27 <div id="approval" style="display: none">
28 <img src="http://localhost:8080/gadgets/files/samplecontainer/examples/new.gif">
29 <a href="#" id="personalize">Personalize this gadget</a>
32 <div id="waiting" style="display: none">
34 <a href="#" id="approvaldone">I've approved access</a>
35 once you've approved access to your data.
38 <script src="http://localhost:8080/gadgets/files/samplecontainer/examples/popup.js"></script>
40 <script type="text/javascript">
42 return document.getElementById(x);
45 function showOneSection(toshow) {
46 var sections = [ 'main', 'approval', 'waiting' ];
47 for (var i=0; i < sections.length; ++i) {
51 el.style.display = "block";
53 el.style.display = "none";
58 function fetchData() {
59 url = "http://localhost:9090/oauth-provider/echo";
61 params[gadgets.io.RequestParameters.CONTENT_TYPE] =
62 gadgets.io.ContentType.TEXT;
63 params[gadgets.io.RequestParameters.AUTHORIZATION] =
64 gadgets.io.AuthorizationType.OAUTH;
65 params[gadgets.io.RequestParameters.METHOD] =
66 gadgets.io.MethodType.GET;
68 gadgets.io.makeRequest(url, function (response) {
70 if (response.oauthApprovalUrl) {
71 popup = shindig.oauth.popup({
72 destination: response.oauthApprovalUrl,
74 onOpen: function() { showOneSection('waiting'); },
75 onClose: function() { fetchData(); }
77 $('personalize').onclick = popup.createOpenerOnClick();
78 $('approvaldone').onclick = popup.createApprovedOnClick();
79 showOneSection('approval');
80 } else if (response.data) {
81 $('main').appendChild(document.createTextNode(response.data));
82 showOneSection('main');
84 var whoops = document.createTextNode(
85 'OAuth error: ' + response.oauthError + ': ' +
86 response.oauthErrorText);
87 $('main').appendChild(whoops);
88 showOneSection('main');
93 gadgets.util.registerOnLoadHandler(fetchData);