java - oAuth 2.0 for google apps audit api -
i using following method oauth credentials google apps audit api
string consumer_key = "consumer_key"; string consumer_secret = "consumer_secret"; googleoauthparameters oauthparameters = new googleoauthparameters(); oauthparameters.setoauthconsumerkey(consumer_key); oauthparameters.setoauthconsumersecret(consumer_secret); oauthparameters .setscope("https://apps-apis.google.com/a/feeds/compliance/audit/ https://www.googleapis.com/auth/userinfo.email"); oauthparameters .setoauthcallback("url_where_i_handle_callback_from_google"); googleoauthhelper oauthhelper = new googleoauthhelper( new oauthhmacsha1signer()); oauthhelper.getunauthorizedrequesttoken(oauthparameters); req.getsession().setattribute("tokensecret", oauthparameters.getoauthtokensecret()); string approvalpageurl = oauthhelper .createuserauthorizationurl(oauthparameters); resp.sendredirect(approvalpageurl); //handle on oauth callback , retrieving oauth token string oauthtoken = req.getparameter("oauth_token"); if (oauthtoken != null) { googleoauthhelper oauthhelper = new googleoauthhelper( new oauthhmacsha1signer()); googleoauthparameters oauthparameters = new googleoauthparameters(); oauthparameters.setoauthconsumerkey(consumer_key); oauthparameters.setoauthconsumersecret(consumer_secret); oauthparameters.setoauthtokensecret((string) req.getsession() .getattribute("tokensecret")); oauthhelper.getoauthparametersfromcallback(req.getquerystring(), oauthparameters); string accesstoken = oauthhelper.getaccesstoken(oauthparameters); string accesstokensecret = oauthparameters.getoauthtokensecret(); }
then signed audit service using :
googleoauthparameters oauthparameters = new googleoauthparameters(); oauthparameters.setoauthconsumerkey(consumer_key); oauthparameters.setoauthconsumersecret(consumer_secret); oauthparameters.setoauthtoken(accesstoken ); oauthparameters.setoauthtokensecret(accesstoken ); auditservice service = new auditservice(<domain_name>,<app_id>); service.setoauthcredentials(oauthparameters, new oauthhmacsha1signer());
now problem it's oauth 1 using oauthhmacsha1signer()
.i want oauth 2.0 not getting resources tells how using java clients. consumer_key , consumer_secret,i getting https://accounts.google.com/managedomains while want use client_id , client_secret https://code.google.com/apis/console oauth 2.
please provide code example oauth 2 using google java client libs or provide links o tutorials.
thanks
i hope 1 of these out -
a lot of snippets might find useful, on link - http://code.google.com/p/google-oauth-java-client/wiki/oauth2
Comments
Post a Comment