2011-12-20 14 views
1

私はこのエラーがあります:GAEのOAuthのJava:認証なしのヘッダー情報

WARNING: Authentication error: Unable to respond to any of these challenges: {} 
Exception : No authentication header information 

私は日食とGWTを使用しています。 私のコードで何が間違っているのか分かりません。 ご協力いただければ幸いです。

ありがとうございます。

クライアント側エントリポイントクラス:

private static final String GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/auth"; 
private static final String GOOGLE_CLIENT_ID = "xxxxxxx.apps.googleusercontent.com"; 
private static final String CONTACTS_SCOPE = "https://www.google.com/m8/feeds"; 
private static final Auth AUTH = Auth.get(); 

public void onModuleLoad() { 
     final AuthRequest req = new AuthRequest(GOOGLE_AUTH_URL, GOOGLE_CLIENT_ID).withScopes(CONTACTS_SCOPE); 

    AUTH.login(req, new Callback<String, Throwable>() { 
     public void onSuccess(String token) {    
      ABASession.setToken(token); 
     } 

     public void onFailure(Throwable caught) { 
      Window.alert("Error:\n" + caught.getMessage()); 
     } 
    }); 
} 

私は後で使用するクラスにトークンを格納します。

サーバー側:ContactServiceImpl(RPC GAE手順)

以前に格納されたトークンは、その後RPCを通過する// 公共リストprintAllContacts(文字列トークン){ 試し{=新しいGoogleOAuthParameters GoogleOAuthParametersのoauthParameters() ;

 oauthParameters.setOAuthConsumerKey("My consumer key"); 
     oauthParameters.setOAuthConsumerSecret("My consumer secret"); 

     PrivateKey privKey = getPrivateKey("certificate/akyosPrivateKey.key"); 

     OAuthRsaSha1Signer signer = new OAuthRsaSha1Signer(privKey); 

     ContactsService service = new ContactsService("XXX"); 
     service.setProtocolVersion(ContactsService.Versions.V3); 
     oauthParameters.setOAuthToken(token); 
     service.setOAuthCredentials(oauthParameters, signer); 

     // Request the feed 
     URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/default/[email protected]"); 

     ContactFeed resultFeed = service.getFeed(feedUrl, ContactFeed.class); 
     for (ContactEntry entry : resultFeed.getEntries()) { 
      for (Email email : entry.getEmailAddresses()) { 
       contactNames.add(email.getAddress()); 
      } 
     } 
     return contactNames; 
    } catch (Exception e) { 
     System.err.println("Exception : " + e.getMessage()); 
    } 
    return null; 
} 

答えて

1

セットスコープ

oauthParameters.setScope("http://www.google.com/m8/feeds/contacts/default/full"); 
関連する問題