-1

I have set the SOCIAL_AUTH_LINKEDIN_FIELD_OAUTH2_SELECTORS field in my Django Settings per the instructions for LinkedIn configurations here: http://psa.matiasaguirre.net/docs/backends/linkedin.html

But when I run the authentication the additional email selector added to that setting is not added to the list of selectors in the backend call.

When I remove the field SOCIAL_AUTH_LINKEDIN_FIELD_OAUTH2_SELECTORS I get an error that it is missing:

'Settings' object has no attribute 'SOCIAL_AUTH_LINKEDIN_FIELD_OAUTH2_SELECTORS'

So I know I am using the correct settings name.

None of the added params make it to the backend though:

settings.SOCIAL_AUTH_LINKEDIN_FIELD_OAUTH2_SELECTORS = ['id', 'recommendations-received', 'positions', 'email-address', 'headline', 'industry', 'first-name', 'last-name', 'location', 'num-connections', 'skills']

I printed out the result of the backend and always just get the default selector list:

[edited backends/linkedin.py from https://github.com/omab/python-social-auth/blob/master/social/backends/linkedin.py#L32]

def user_details_url(self):
    # use set() since LinkedIn fails when values are duplicated
    fields_selectors = list(set(['first-name', 'id', 'last-name'] +
                            self.setting('FIELD_SELECTORS', [])))

    print fields_selectors

    # user sort to ease the tests URL mocking
    fields_selectors.sort()
    fields_selectors = ','.join(fields_selectors)
    return self.USER_DETAILS.format(fields_selectors)

#> ['first-name', 'id', 'last-name']

How can I add selectors through DJANGO Settings to expand the data returned when authenticating?

Sean
  • 2,412
  • 3
  • 25
  • 31
  • I think the right parameter is to use `SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS` – Aamir Rind Dec 13 '14 at 02:09
  • ALthough using that didn't cause an error non of the selctors listed for that param worked :-/ I figured a way out but it is a bit of a hack; I thknk the problem is a bug with the system. I will list it as an answer below. – Sean Dec 16 '14 at 20:07

1 Answers1

2

Aamir suggestion worked!:

SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS

I ended up adding a print statement to social.strategies.django_strategies and got alisting of all the settings being pulled:

    def get_setting(self, name):
        print name
        return getattr(settings, name)

Listing...

# SOCIAL_AUTH_REDIRECT_IS_HTTPS
# REDIRECT_IS_HTTPS
# SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY
# SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET 
# SOCIAL_AUTH_LINKEDIN_OAUTH2_REQUESTS_TIMEOUT 
# SOCIAL_AUTH_REQUESTS_TIMEOUT
# REQUESTS_TIMEOUT 
# SOCIAL_AUTH_LINKEDIN_OAUTH2_URLOPEN_TIMEOUT 
# SOCIAL_AUTH_URLOPEN_TIMEOUT
# URLOPEN_TIMEOUT 
# SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS

....

Sean
  • 2,412
  • 3
  • 25
  • 31