HI,

Now I remember why I choose AuthSub : AuthSub is documented in AppEngine 
docs, where OAuth is not (or not so)

It is a nightmare to try to understand how OAuth must be implemented in 
Java...and that's don't work yet.

I have trying to use OAuth using a third lib "Scribe" for  the OAuth 
protocol.

Here is my code : 

      String scope = 
"http://www.google.com/calendar/feeds/default/allcalendars/full";;
      String RequestBackUrl = 
"http://timegrouper2011.appspot.com/RetrieveTokenOAuth?back=y";;

        
        if (get("back").equals("y")) {                             // step 2

            echoln("GET BACK TOKEN...");

            OAuthService service = new ServiceBuilder()     // 'scribe 
service
            .provider(GoogleApi.class)
            .apiKey("timegrouper2011.appspot.com")
            .apiSecret("xxxxxxxxxxxxxxxxxxxx")              // here stand my 
api secretprovided by Google after registration
            .callback(RequestBackUrl)
            .scope(scope)                                               // 
calendar scope
            .build();
            
            Token requestToken = service.getRequestToken();    // basic 
token (for what use here ? ) hmmm

             String verifierStr  = get("oauth_verifier");                    
// verifier  from url
             String authToken = get("oauth_token");                    // 
oauthtoken from url
             
             
             Verifier verifier = new Verifier(verifierStr);
             
             resp.getWriter().println("QueryString back verifier : " + 
verifierStr + "<br>");
             resp.getWriter().println("QueryString back auth : " + authToken 
+ "<br>");
             resp.getWriter().println("Service request token : " + 
requestToken + "<br>");
             
             Token accessToken;
             
             
            try {
                accessToken = service.getAccessToken(requestToken, 
verifier);
            } catch (Exception e) {
                 this.error("auth Tokenerror : " + e.toString() + "<br>");
                return;
            }

            resp.getWriter().println("<br><br><table>");
            
             resp.getWriter().println("<tr>td>Token non auth :</td><td> " + 
requestToken + "</tr></tr>");
             resp.getWriter().println("<tr>td>Token reply :</td><td> " + 
authToken + "</tr></tr>");
             resp.getWriter().println("<tr>td>auth Token : </td><td> " + 
accessToken + "</tr></tr>");
             resp.getWriter().println("</table>"); 
        }
        else {                                                                  
                                      
// STEP 1
            //         String scope = 
"https://www.google.com/calendar/feeds/";;
    
       
            OAuthService service = new ServiceBuilder()
            .provider(GoogleApi.class)
            .apiKey("timegrouper2011.appspot.com")
            .apiSecret("xxxxxxxxxxxxxxxxxxxx")
            .callback(RequestBackUrl)
            .scope(scope)                         // il parait qu'il faut 
pas le mettre mais sinon erreur...mais pourtant c'est l'inverse
            .build();

            
            Token requestToken = service.getRequestToken();
            String your_token = requestToken.getToken();

            
            resp.getWriter().println("Token : " + your_token);
            
            
            
            String step2url 
="https://www.google.com/accounts/OAuthAuthorizeToken";;
            step2url = step2url + "?oauth_token="+your_token;
            
            resp.getWriter().println("<br>Token auth url : <br><a href='" + 
step2url + "'>Log me in...</a>");

}


Something go wrong on step 2 : 

Exemple of result : 

GET BACK TOKEN...
QueryString back verifier : VO9K5Ykeu4zgFzpihAlsRGev
QueryString back auth : 4/qaWXlhxFvuWCenYtCWKZkEz7cU7G
Service request token : Token[4/ijJxtFuBJMvkA-7bmF7Ihk5XpgMX , 
vIzcE+IjLrGxz0w+5jJ96+Lh]

ERROR : auth Tokenerror : org.scribe.exceptions.OAuthException: Response 
body is incorrect. Can't extract a token from this: 'The token is invalid. '

      

Any idea of what's I'm doing wrong ?

Thanks,

tleboulay  

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" 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://code.google.com/apis/calendar/community/forum.html

Reply via email to