Allo, Jérôme,

Thanks for the confirmation. I set up the service definition to extract the 
email from the first item in Groovy and it works:

    allowedAttributes:
    {   
        @class: java.util.TreeMap
        mail: "groovy { return attributes['emails'][0].getEmail() }"
    }   

Thank you!

On Friday, October 20, 2017 at 2:20:26 AM UTC-4, leleuj wrote:
>
> Hi,
>
> In pac4j, user profiles are available via the CommonProfile class and in 
> that case, from the Google2Profile which has a specific logic to get the 
> emails: 
> https://github.com/pac4j/pac4j/blob/master/pac4j-oauth/src/main/java/org/pac4j/oauth/profile/google2/Google2Profile.java#L22
>
> We can easily add a toString to the Google2Email object. Can't you get the 
> emails attribute and extract the first email if it exists?
>
> Thanks.
> Best regards,
> Jérôme
>
>
> On Thu, Oct 19, 2017 at 8:33 PM, Carlos M. Fernández <
> [email protected] <javascript:>> wrote:
>
>> Hello,
>>
>> I'm setting up an instance of CAS 5.1.5 that delegates authentication to 
>> Google. I currently have it working more or less as intended in my 
>> development sandbox, however I've hit one issue that I have yet to work 
>> around.
>>
>> Google returns a very big integer as the user ID, so I'd like to grab the 
>> email address from an attribute instead. However!, instead of an email 
>> address or a list of addresses, PAC4J seems to populate the emails 
>> attribute with an object ref. The logs show messages like the one below, 
>> and the attribute is passed as shown in the logs to the application:
>>
>> 2017-10-19 13:57:00,165 INFO 
>> [org.apereo.cas.authentication.AbstractAuthenticationManager] - 
>> <Authenticated principal [115266970958975232474] with attributes 
>> [{access_token=ya29.Glseeminglyrandomstringn2p6E-Mh2iNanotherverylongpieceofstringG5h9QK_DDPb01xtM8RQg,
>>  
>> displayName=Carlos M. Fernández, 
>> emails=[org.pac4j.oauth.profile.google2.Google2Email@7e40686c], 
>> gender=MALE, image.url=
>> https://lh6.googleusercontent.com/-IPbS/very/long/url/to/the/photo.jpg?sz=50,
>>  
>> language=en, name.familyName=Fernández, name.givenName=Carlos M., url=
>> https://plus.google.com/+googleplusurl}] via credentials 
>> [[org.apereo.cas.authentication.principal.ClientCredential@48ad0f08[id=115975669723242095874]]].>
>>
>> It seems that this Google2Email object 
>> <https://github.com/pac4j/pac4j/blob/master/pac4j-oauth/src/main/java/org/pac4j/oauth/profile/google2/Google2Email.java>
>>  
>> contains the email address that I want to retrieve, however the class 
>> doesn't implement toString(). Is this perhaps a bug in the CAS PAC4J 
>> support code? Could I perhaps extract it through a Groovy script in the 
>> service definition?
>>
>> TIA,
>> --
>> Carlos
>>
>> -- 
>> - Website: https://apereo.github.io/cas
>> - Gitter Chatroom: https://gitter.im/apereo/cas
>> - List Guidelines: https://goo.gl/1VRrw7
>> - Contributions: https://goo.gl/mh7qDG
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CAS Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/a/apereo.org/d/msgid/cas-user/830989b8-1050-4468-b4de-66dfc6939b2e%40apereo.org
>>  
>> <https://groups.google.com/a/apereo.org/d/msgid/cas-user/830989b8-1050-4468-b4de-66dfc6939b2e%40apereo.org?utm_medium=email&utm_source=footer>
>> .
>>
>
>

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/01ab34c8-21b8-479e-ad69-1980b0fdec80%40apereo.org.

Reply via email to