/** * Fetch a credential associated with this request. * * @param req Request object to use as context for fetching the credential. * @return Credential object for this request and user. */ protected Credential getCredential(HttpServletRequest req) throws IOException { PersistenceManager pm = (PersistenceManager) req.getAttribute(AUTH_PERSISTENCE_MANAGER); String userId = getUserId(); TwoLeggedFlow oauthFlow = newFlow(userId); Credential cred = oauthFlow.loadOrCreateCredential(pm); return cred; }