Hi,
I tried to implement the google connector with my application which worked fine so far. I call this url to let the user log in with his google account.
public String genGoogleLoginUrl() {
AuthAPI authAPI = new AuthAPI(domain, clientId, clientSecret);
return authAPI.authorizeUrl(
"https://dev-de.testapp.com:8443/testapp/socialauth/google/response")
.withConnection("google-oauth2")
.build();
}
The Callback provides me with a code I can then exchange for an access_token.
public String getUserByCode(String code) {
AuthAPI authAPI = new AuthAPI(domain, clientId, clientSecret);
Object info =
authAPI.exchangeCode(code,
"https://dev-de.testapp.com:8443/testapp/socialauth/google/response")
.setScope("openid profile email")
.setAudience("https://"+domain+"/userinfo")
.execute();
if (info != null){
return ((TokenHolder)info).getAccessToken();
}
return "https://dev-de.testapp.com:8443/testapp/login/";
}
I now have a pretty long access_token. What I need though is the email address of the user. And here lays my problem. I try to call the /userInfo:
private boolean getUserData(String accessToken) {
AuthAPI authAPI = new AuthAPI(domain, clientId, clientSecret);
Request request = authAPI.userInfo(accessToken);
try {
Object info = request.execute();
if (info != null){
return true;
}
} catch (APIException exception) {
// api error
System.out.println("api error" + exception.getMessage());
} catch (Auth0Exception exception) {
System.out.println("request error: " + exception.getMessage());
}
return false;
}
But it throws an API exception with the message “Request failed with status code 401: invalid credentials”.
The API is set to RS256 signing and I added “openid” in the scopes menu. Did I miss something? Any help would be much appreciated.