【问题标题】:GAE OAuth Java: No authentication header informationGAE OAuth Java:没有身份验证标头信息
【发布时间】:2012-02-20 15:25:30
【问题描述】:

我有这个错误:

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

我在 Eclipse 中使用 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 过程)

//之前存储的token然后通过RPC传递 公共列表 printAllContacts(字符串令牌){ 尝试 { GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();

        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/full?xoauth_requestor_id=xxx.yyy@gmail.com");

        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;
}

【问题讨论】:

    标签: java google-app-engine oauth


    【解决方案1】:

    设置范围

    oauthParameters.setScope("http://www.google.com/m8/feeds/contacts/default/full");
    

    【讨论】:

      猜你喜欢
      • 2012-12-30
      • 2015-03-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多