dcorking / google-wave-resources

Automatically exported from code.google.com/p/google-wave-resources
0 stars 0 forks source link

Using OAuth for Blogger Data API from a Wave Gadget causes "Error 403" #734

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello folks,

I'm quite a newbie when it comes to OpenSocial Gadgets and the Google Data
APIs and I hope this is the right place for my issue (I apologize if it is
not).

I am trying to use OAuth to authenticate for the Blogger Data API within a
Gadget in Google Wave (which -- as far as i know -- runs in an OpenSocial
container). Below is the abbreviated code for the Gadget:

======================== CODE START ========================
<Module>

<ModulePrefs title="Blogger.com Gadget">
 <Require feature="opensocial-0.8" />
 <Require feature="wave" />
 <Require feature="dynamic-height" />
 <OAuth>
  <Service name="google">
   <Access url="https://www.google.com/accounts/OAuthGetAccessToken"
method="GET" />
   <Request
url="https://www.google.com/accounts/OAuthGetRequestToken?scope=http://www.blogg
er.com/feeds/"
mehtod="GET" />
   <Authorization
url="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=http://o
auth.gmodules.com/gadgets/oauthcallback"
/>
  </Service>
 </OAuth>
</ModulePrefs>

<Content type="html"><![CDATA[ 

<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script type="text/javascript"
src="http://maxspeicher.orgfree.com/plebot/json2.js"></script>

<script type="text/javascript">

var _bloggerService;

function displayDiv(id) { ... }

function bloggerCallback(response)
{
  if (response.oauthApprovalUrl)
  {
    ...
  }
  else if (response.feed)
  {
    showBlogs(response.feed);
    displayDiv('authorized');
  }
  else
  {
    // The Gadget always ends up here
    alert(response.stack);
  }
}

function showBlogs(feed)
{
  var blogs = feed.getEntries();

  if (!blogs.length)
    document.getElementById('authorized').innerHTML = 'No blogs available!';
  else
  {
    for (i=0; i<blogs.length; i++)
      document.getElementById('authorized').innerHTML +=
blogs[i].getTitle().getText();
  }

  gadgets.window.adjustHeight();
}

function fetchData()
{
  _bloggerService.getBlogFeed('http://www.blogger.com/feeds/default/blogs',
bloggerCallback, bloggerCallback);
}

function initBlogger()
{
  _bloggerService = new google.gdata.blogger.BloggerService('MAXbot-Test');

  _bloggerService.useOAuth('google');

  fetchData();
}

function init()
{
  google.load('gdata', '1.x', {'packages': ['blogger']});
  google.setOnLoadCallback(initBlogger);
}

gadgets.util.registerOnLoadHandler(init);

</script>

...

]]></Content>

</Module>
======================== CODE END ========================

However, each single run of the Gadget end up showing this alert message:

Error("403 Error")@:0
([object
Object])@http://www.google.com/uds/api/gdata/1.10/8ae1e081515b3d01d252fc9bd04093
dc/core,mediarss,opensearch,atom,threading,app,gdata,blogger.I.js:92
([object
Object])@http://www.google.com/uds/api/gdata/1.10/8ae1e081515b3d01d252fc9bd04093
dc/core,mediarss,opensearch,atom,threading,app,gdata,blogger.I.js:8
processResponse("http://www.blogger.com/feeds/default/blogs?user-agent=PLEbot-Te
st%2520GData-JavaScript%252Fdev%25201271453073595-590&alt=json",(function
() {return a[lb](l, arguments);}),[object Object],[object
XMLHttpRequest],[object
Event])@https://www-wave-opensocial.googleusercontent.com/gadgets/js/core:dynami
c-height:opensocial-0.8:security-token:wave.js?v=38c33f39c56d33d8acef1e07f3d52e8
&container=wave&debug=0:1120
([object
Event])@https://www-wave-opensocial.googleusercontent.com/gadgets/js/core:dynami
c-height:opensocial-0.8:security-token:wave.js?v=38c33f39c56d33d8acef1e07f3d52e8
&container=wave&debug=0:77

...and I have asolutely no clue why this is the case. I would be very very
happy if someone was able to give me a little hint. Thanks a lot!

--Max

Original issue reported on code.google.com by max1...@gmx.net on 16 Apr 2010 at 9:29