davmail
davmail copied to clipboard
Is this project dead? Need Graph API backend and token username is also broken.
Project hasn't been updated in a long time. OAuth2 is no good for "modern" Outlook access anymore. Microsoft 365 Online (Business) costs at least $6/month to add Entra's app-based API Permissions to use Outlook 365 API (Personal). Graph API is the only free way, but it's not really implemented in davmail... And there's no local web host to handle https responses from redirect_url. Need POP3 Proxy->Graph API (Outlook 365/Exchange).
Tried:
- client ID (office): d3590ed6-52b3-4102-aeff-aad2292ab01c
- redirect_url: urn:ietf:wg:oauth:2.0:oob?code
- got key, pasted in O365Manual mode
problem: davmail - Can't find resource for bundle java.util.PropertyResourceBundle, key Authenticated username live.com#[email protected] does not match [email protected]. It's mixing up: "unique_name":"live.com#[email protected]" and complaining about it not matching "email":"[email protected]".
Token: {"aud":"d3590ed6-52b3-4102-aeff-aad2292ab01c","iss":"https://sts.windows.net/3ceb7ded-6237-4abf-aed0-f741fb55330a/","iat":X,"nbf":X,"exp":X,"altsecid":"1:live.com:X","amr":["pwd"],"email":"[email protected]","family_name":"X","given_name":"X","idp":"live.com","idtyp":"user","ipaddr":"X","name":"X","oid":"X","puid":"X","rh":"","sub":"","tid":"X","unique_name":"live.com#[email protected]","ver":"1.0","xms_idrel":"4 1"}
.... username = tokenBody.getString("unique_name"); ?
You could check "email" field too... or parse on unique_name... past #
=========================
token = O365Token.build(tenantId, clientId, redirectUri, code, password);
LOGGER.debug("Authenticated username: " + token.getUsername());
if (username != null && !username.isEmpty() && !username.equalsIgnoreCase(token.getUsername())) {
throw new DavMailAuthenticationException("Authenticated username " + token.getUsername() + " does not match " + username);
}
// get username from id_token
String idToken = jsonToken.optString("id_token");
if (idToken != null && idToken.contains(".")) {
String decodedJwt = IOUtil.decodeBase64AsString(idToken.substring(idToken.indexOf("."), idToken.lastIndexOf(".")));
try {
JSONObject tokenBody = new JSONObject(decodedJwt);
LOGGER.debug("Token: " + tokenBody);
username = tokenBody.getString("unique_name");
} catch (JSONException e) {
LOGGER.warn("Invalid id_token " + e.getMessage(), e);
}
}