Hi,

Javascript error is fixed. But now Im getting
"net.oauth.OAuthProblemException: signature_invalid"
exception.
Please help!!!!

Raj


The corrected XML code is:

<?xml version="1.0" encoding="UTF-8"?><Module><ModulePrefs title="make
request........" description="................."><Require
feature="opensocial-0.7"/><Require feature="dynamic-height"/></
ModulePrefs><Content type="html"><![CDATA[<script>function onLoad()
{var params={};params[gadgets.io.RequestParameters.AUTHORIZATION] =
gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] =
gadgets.io.MethodType.GET;
params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.TEXT;gadgets.io.makeRequest('http://<domain
name>/HiqOrkut/authenticate.do', function(response)
{          if(response.errors)          {        //shows: Errors:
Error 404            alert("Errors:" + response.errors
+"=="+response.data+"http://<domain name>/HiqOrkut/
authenticate.do");          }          else          {            var
data = response.data;        // do stuff          }        },
params); };function authResponse(data){for(var i in data){alert(i
+'='+data[i]);}};onLoad();</script><div id="content_div">Loading...</
div>]]></Content></Module>

On Mar 25, 12:53 pm, Raj <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I need to authenticate the user before accessing the application.
> Below is the code which i have used, im getting javascript error and
> the request is not submitted to the server.
> Server side code is in java.
>
> Any help greatly appreciated.
>
> Thanks in advance.
> Raj
>
> Gadget XML code:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
> <ModulePrefs title="json.. Your HolidayIQ" author="www.holidayiq.com"
> author_location="Bangalore" author_email="[EMAIL PROTECTED]">
> <Require feature="opensocial-0.7" />
>  </ModulePrefs><Content type="html">
> <![CDATA[
>
> <script type="text/javascript">
>
> function makeSignedRequest()
> {
>  var params = {};
>  params[gadgets.io.RequestParameters.AUTHORIZATION] =
> gadgets.io.AuthorizationType.SIGNED;
>  params[gadgets.io.RequestParameters.CONTENT_TYPE] =
> gadgets.io.ContentType.TEXT;
>  params[gadgets.io.RequestParameters.METHOD] =
> gadgets.io.MethodType.POST;
>
> var url = "http://localhost:9090/HiqOrkut/authenticate.do";;
>
> gadgets.io.makeRequest(url,authResponse, params);
>
> }
>
> function authResponse(data)
> {
> for(var i in data)
> {
> alert(i+'='+data[i]);
>
> }
> }
>
> _IG_RegisterOnloadHandler(makeSignedRequest);
>
> </script>
> <div id="content_div">Loading...</div>
>
>  ]]>
> </Content></Module>
>
> Server code:
> package com.orkut.pl.action.hiqOrkut;
>
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
>
> import net.oauth.OAuthAccessor;
> import net.oauth.OAuthConsumer;
> import net.oauth.OAuthMessage;
> import net.oauth.OAuthServiceProvider;
> import net.oauth.server.OAuthServlet;
> import net.oauth.signature.RSA_SHA1;
>
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
>
> public class AuthenticateAction extends Action {
>
>         private static final String certificate =
>                  "-----BEGIN CERTIFICATE-----\n"
>                 
> +"MIIDHDCCAoWgAwIBAgIJAMbTCksqLiWeMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV
> \n"
>                 
> +"BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIG
> \n"
>                 
> +"A1UEChMLR29vZ2xlIEluYy4xDjAMBgNVBAsTBU9ya3V0MQ4wDAYDVQQDEwVscnlh
> \n"
>                 
> +"bjAeFw0wODAxMDgxOTE1MjdaFw0wOTAxMDcxOTE1MjdaMGgxCzAJBgNVBAYTAlVT
> \n"
>                 
> +"MQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChML
> \n"
>                 
> +"R29vZ2xlIEluYy4xDjAMBgNVBAsTBU9ya3V0MQ4wDAYDVQQDEwVscnlhbjCBnzAN
> \n"
>                 
> +"BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAseBXZ4NDhm24nX3sJRiZJhvy9eDZX12G
> \n"
>                 
> +"j4HWAMmhAcnm2iBgYpAigwhVHtOs+ZIUIdzQHvHeNd0ydc1Jg8e+C+Mlzo38OvaG
> \n"
>                 
> +"D3qwvzJ0LNn7L80c0XVrvEALdD9zrO+0XSZpTK9PJrl2W59lZlJFUk3pV+jFR8NY
> \n"
>                 
> +"eB/fto7AVtECAwEAAaOBzTCByjAdBgNVHQ4EFgQUv7TZGZaI+FifzjpTVjtPHSvb
> \n"
>                 
> +"XqUwgZoGA1UdIwSBkjCBj4AUv7TZGZaI+FifzjpTVjtPHSvbXqWhbKRqMGgxCzAJ
> \n"
>                 
> +"BgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEU
> \n"
>                 
> +"MBIGA1UEChMLR29vZ2xlIEluYy4xDjAMBgNVBAsTBU9ya3V0MQ4wDAYDVQQDEwVs
> \n"
>                 
> +"cnlhboIJAMbTCksqLiWeMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEA
> \n"
>                 
> +"CETnhlEnCJVDXoEtSSwUBLP/147sqiu9a4TNqchTHJObwTwDPUMaU6XIs2OTMmFu
> \n"
>                 
> +"GeIYpkHXzTa9Q6IKlc7Bt2xkSeY3siRWCxvZekMxPvv7YTcnaVlZzHrVfAzqNsTG
> \n"
>                 +"P3J//C0j+8JWg6G+zuo5k7pNRKDY76GxxHPYamdLfwk=\n"
>                 +"-----END CERTIFICATE-----";
>
>     /*   "-----BEGIN CERTIFICATE-----\n"
>      + "MIIBpjCCAQ
> +gAwIBAgIBATANBgkqhkiG9w0BAQUFADAZMRcwFQYDVQQDDA5UZXN0\n"
>      +
> "IFByaW5jaXBhbDAeFw03MDAxMDEwODAwMDBaFw0zODEyMzEwODAwMDBaMBkxFzAV\n"
>      +
> "BgNVBAMMDlRlc3QgUHJpbmNpcGFsMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n"
>      + "gQC0YjCwIfYoprq/
> FQO6lb3asXrxLlJFuCvtinTF5p0GxvQGu5O3gYytUvtC2JlY\n"
>      + "zypSRjVxwxrsuRcP3e641SdASwfrmzyvIgP08N4S0IFzEURkV1wp/
> IpH7kH41Etb\n"
>      + "mUmrXSwfNZsnQRE5SYSOhh
> +LcK2wyQkdgcMv11l4KoBkcwIDAQABMA0GCSqGSIb3\n"
>      + "DQEBBQUAA4GBAGZLPEuJ5SiJ2ryq+CmEGOXfvlTtEL2nuGtr9PewxkgnOjZpUy
> +d\n"
>      + "4TvuXJbNQc8f4AMWL/tO9w0Fk80rWKp9ea8/
> df4qMq5qlFWlx6yOLQxumNOmECKb\n"
>      + "WpkUQDIDJEoFUzKMVuJf4KO/FJ345+BNLGgbJ6WujreoM1X/gYfdnJ/J\n"
>      + "-----END CERTIFICATE-----";*/
>
>         public ActionForward execute(ActionMapping mapping, ActionForm form,
>                         HttpServletRequest request, HttpServletResponse 
> response)
>                         throws Exception
>         {
>                 String target="success";
>                 try {
>                         System.out.println("in authenticate action
> class*********************");
>                           OAuthServiceProvider provider = new 
> OAuthServiceProvider(null,
> null,null);
>                           System.out.println("print provider ==="+provider);
>                           OAuthConsumer consumer = new OAuthConsumer(null, 
> "orkut.com",
> null,provider);
>                           System.out.println("print cosumer==="+consumer);
>                           consumer.setProperty(RSA_SHA1.X509_CERTIFICATE, 
> certificate);
>                           OAuthMessage message = 
> OAuthServlet.getMessage(request, null);
>                           System.out.println("print message=="+message);
>                           OAuthAccessor accessor = new 
> OAuthAccessor(consumer);
>                           message.validateSignature(accessor);
>                           System.out.println("in authenticate action
> class*********************");
>                          // return true;
>                         } catch (Exception e) {
>                           //not signed or some other issue.
>                                 System.out.println("exception in 
> authenticate==="+e);
>                                 e.printStackTrace();
>                                 target="failure";
>
>                         }
>
>                 return (mapping.findForward(target));
>         }
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenSocial Application Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to