92 ClientScopeModel offlineScope = KeycloakModelUtils.getClientScopeByName(realm, OAuth2Constants.OFFLINE_ACCESS);
93 if (offlineScope == null) {
94 throw new OAuthErrorException(OAuthErrorException.INVALID_GRANT,
"Offline Access scope not found");
97 if (client.isConsentRequired()) {
99 UserConsentModel consent = session.users().getConsentByClient(realm, user.getId(), client.getId());
100 if (consent != null) {
101 if (client.isDisplayOnConsentScreen()) {
102 consent.addGrantedClientScope(client);
104 if (offlineScope.isDisplayOnConsentScreen()) {
105 consent.addGrantedClientScope(offlineScope);
107 session.users().updateConsent(realm, user.getId(), consent);