22
33import com .github .scribejava .core .model .*;
44import com .github .scribejava .core .oauth .OAuth20Service ;
5+
6+ import org .apache .commons .lang3 .StringUtils ;
7+
58import org .pac4j .core .client .IndirectClient ;
69import org .pac4j .core .context .HttpConstants ;
710import org .pac4j .oauth .config .OAuth20Configuration ;
1215/**
1316 * OAuth 2.0 profile creator.
1417 *
18+ * OSF CAS Customization: modified {@code addAccessTokenToProfile} to include refresh token in profile attributes.
19+ *
1520 * @author Jerome Leleu
21+ * @author Longze Chen
1622 * @since 2.0.0
23+ * @version 4.1.0
1724 */
1825public class OAuth20ProfileCreator <U extends OAuth20Profile >
1926 extends OAuthProfileCreator <OAuth20Credentials , U , OAuth20Configuration , OAuth2AccessToken , OAuth20Service > {
2027
28+ private static final String REFRESH_TOKEN = "refresh_token" ;
29+
2130 public OAuth20ProfileCreator (final OAuth20Configuration configuration , final IndirectClient client ) {
2231 super (configuration , client );
2332 }
@@ -33,6 +42,11 @@ protected void addAccessTokenToProfile(final U profile, final OAuth2AccessToken
3342 final String token = accessToken .getAccessToken ();
3443 logger .debug ("add access_token: {} to profile" , token );
3544 profile .setAccessToken (token );
45+ final String refreshToken = accessToken .getRefreshToken ();
46+ if (StringUtils .isNoneBlank (refreshToken )) {
47+ logger .debug ("add refresh_token: {} to profile" , token );
48+ profile .addAttribute (REFRESH_TOKEN , refreshToken );
49+ }
3650 }
3751 }
3852
0 commit comments