Coder Social home page Coder Social logo

python-linkedin's People

Contributors

abraham avatar adrian-sgn avatar ayyar avatar b3nelof0n avatar darune avatar devinbarry avatar iacxc avatar ikudriavtsev avatar ismix avatar ivankravets avatar jayzeng avatar johnfraney avatar kitsunde avatar lucavandro avatar lyroge avatar marshyang avatar mblakele avatar ozgur avatar ptwobrussell avatar samuelmarks avatar yprez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-linkedin's Issues

Retrieve email address of connections

I am trying to retrieve email address of my connections using get_connections and get_profile methods. But it doesn't return the email address.

responseJson =application.get_connections(selectors=["id","first-name","last-name","email-address"])

When I call this, it returns only id, first-name and last-name of my connections.

As mentioned in http://developers.linkedin.com/documents/profile-fields#email, I have set r_emailaddress permission also.

Can anyone please help me to get it resolved ?

[Company API] Some address info not returned

When inspecting the company location info, it appears that some of the information that is available via the LinkedIn api is missing; here is some sample information returned:

{u'contactInfo':
    {u'fax': u'+1 (888) 849 7339',
    u'phone1': u'+1 (888) 849 7339'},
    u'address': {
      u'postalCode': u'95054',
      u'city': u'Santa Clara', 
      u'street1': u'Mission City Center, Suite 925'
      }
    }

Additional information could be:

  • street2
  • state
  • country-code
  • region-code

submit_group_post() call returns empty content

When trying to submit a post to a group, the following error is raised:

>>> application.submit_group_post(group_id, title, summary, submitted_url, submitted_image_url, content_title, description)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "linkedin/linkedin.py", line 363, in submit_group_post
    response = response.json()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/models.py", line 733, in json
    return json.loads(self.text, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/simplejson/__init__.py", line 488, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/simplejson/decoder.py", line 389, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

because the response has an empty content that cannot be json decoded.

What is the expected content of a successful response?

python3 support

I am totally new to python. From issue 70 (syntax error), it appears that this package does not support python 3. Why not? Thanks.

Unable to verify access token?

I'm seeing intermittent issues resulting in getting 'Unable to verify access token' from get_profile() after authenticating.

I'm checking if request.session.has_key('linkedin_access_token'): before calling it and it works fine in most cases.

Is this a known issue or am I doing something incorrectly?

Issue with getting the access token

Linkedin's developer documentation states that the URl should have the following structure when making a request for the access
https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code
&code=AUTHORIZATION_CODE
&redirect_uri=YOUR_REDIRECT_URI
&client_id=YOUR_API_KEY
&client_secret=YOUR_SECRET_KEY

Therefore, should the get_access_token() not be rewritten as:

def get_access_token(self, timeout=60):
    assert self.authorization_code, 'You must first get the authorization code'
    qd = {'grant_type': 'authorization_code',
          'code': self.authorization_code,
          'redirect_uri': self.redirect_uri,
          'client_id': self.key,
          'client_secret': self.secret}
    qsl = ['%s=%s' % (urllib.quote(k), urllib.quote(v)) for k, v in qd.items()]
    fullURL = '%s?%s' % (self.ACCESS_TOKEN_URL, '&'.join(qsl))

    response = requests.post(fullURL, timeout=timeout)
    raise_for_error(response)
    response = response.json()
    self.token = AccessToken(response['access_token'], response['expires_in'])
    return self.token

Release version 4.2

The last python-linkedin release is more than one year old. In the meantime, you got many fixes and Python 3 support. Can you please upload the 4.2 version to PyPI? Thanks!

[Group API] Can't get info for more than first 10 posts

Hi,

I have a problem when I want to access the fields of the posts within a group.
To be more specific, I can access the fields for the first 10 posts ( from 0 to 9 ). After the post 9, I get an error from the client: linkedin.exceptions.LinkedInError: 404 Client Error: Not Found: Unknown Error

Do you have any clue?
Thanks!

issue with "import linkedin" in a virtualenv on python 2.6

The library doesn't seem to import consistently when I'm using it within a virtualenv and python 2.6 (am about to try 2.7). I get the following error:

from linkedin import linkedin
Traceback (most recent call last):
File "", line 1, in
File "/Users/geoffwalmsley/Dropbox/WMA/WMA/lib/python2.6/site-packages/linkedin/linkedin.py", line 13, in
from .models import AccessToken, LinkedInInvitation
File "/path_to_virtualenv/lib/python2.6/site-packages/linkedin/models.py", line 4, in
verbose=False, rename=False)
TypeError: namedtuple() got an unexpected keyword argument 'rename'

JSON Error with get_access_token()

I am able to get almost to the end of the flow but I receive a: "ValueError: No JSON object could be decoded" based on the get_access_token() call.

The code:
class LinkedInLogin(webapp2.RequestHandler):

def get(self):
    redirect_url ="http://127.0.0.1:14080/linkedincallback"

    authentication = linkedin.LinkedInAuthentication(api_key, api_secret, redirect_url, ["r_basicprofile","r_emailaddress"])
    self.redirect(authentication.authorization_url)

class LinkedInCallBack(webapp2.RequestHandler):

def get(self):
    redirect_url ="http://127.0.0.1:14080/linkedincallback"

    authentication = linkedin.LinkedInAuthentication(api_key, api_secret, redirect_url, ["r_basicprofile","r_emailaddress"])
    authentication.authorization_code = self.request.GET["code"]
    authentication.get_access_token()

Python 3.4 support not working

Hi @ozgur
I know this issue has been addresses previously in some other issue id. But I somehow am not able to make this work.
I am working on a virtualenvwrapper which is having python 3.4.2

When I run the http_api.py; I get the following output:

Traceback (most recent call last):
File "http_api.py", line 1, in
from linkedin import linkedin
File "/home/Saurabh/.virtualenvs/jobfinder/lib/python3.4/site-packages/linkedin/linkedin.py", line 294
except (requests.ConnectionError, requests.HTTPError), error:
^
SyntaxError: invalid syntax

Please fix this issue as soon as possible, in need urgently.
Thanks

get_companies from a list of companies returns simplejson.scanner.JSONDecodeError

When trying to get details on a list of companies I get the following error

temp = application.get_companies(company_ids=work_id, selectors=['company-type','industries','blog-rss-url','twitter-id','employee-count-range'])
Traceback (most recent call last):
File "", line 1, in
File "/Users/arvindvg/anaconda/lib/python2.7/site-packages/linkedin/linkedin.py", line 336, in get_companies
return response.json()
File "/Users/arvindvg/anaconda/lib/python2.7/site-packages/requests/models.py", line 763, in json
return json.loads(self.text, **kwargs)
File "/Users/arvindvg/anaconda/lib/python2.7/site-packages/simplejson/init.py", line 501, in loads
return _default_decoder.decode(s)
File "/Users/arvindvg/anaconda/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/Users/arvindvg/anaconda/lib/python2.7/site-packages/simplejson/decoder.py", line 393, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is this is can issue with content thats empty that gets returned ? or something else

LastError should be known when the response is not 2xx

When the response is not 2.xx, we are not keeping track of what the server has sent as a response that actually gives information about the error. We somehow need a way to keep the last error in the application instance.

quote_from_bytes() expected bytes

  1. Firstly, the package on Pypi doesn't work, but of course the version on Github can work.
  2. Secondly, we I start the example/http_api.py as server, and then visit localhost in my brower, following errors happen inside:

127.0.0.1 - - [11/Nov/2015 17:11:22] "GET /get_profile HTTP/1.1" 200 -

Exception happened during processing of request from ('127.0.0.1', 56082)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 609, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 344, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 665, in init
self.handle()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/server.py", line 398, in handle
self.handle_one_request()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/server.py", line 386, in handle_one_request
method()
File "http_api.py", line 62, in do_GET
open_new_tab(liw.authentication.authorization_url)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/python_linkedin-4.2-py3.4.egg/linkedin/linkedin.py", line 101, in authorization_url
qsl = ['%s=%s' % (quote(k), quote(v)) for k, v in qd.items()]
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/python_linkedin-4.2-py3.4.egg/linkedin/linkedin.py", line 101, in
qsl = ['%s=%s' % (quote(k), quote(v)) for k, v in qd.items()]
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/parse.py", line 694, in quote
return quote_from_bytes(string, safe)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/parse.py", line 719, in quote_from_bytes
raise TypeError("quote_from_bytes() expected bytes")

TypeError: quote_from_bytes() expected bytes

Wish your help

Update to pypi version

I noticed that this library hasn't been updated recently on pypi, when are you planning to release it?

cannot get access token

Maybe this is a dumb question but I'm totally new to apis and hope to get help.

I am following the instructions in the readme file and when I proceeded to

authentication.authorization_code = '???'
authentication.get_access_token()

I got this error:

linkedin.exceptions.LinkedInError: invalid_request: missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired

I'm using http://localhost:8000 as the return_url. I pasted the link the python printed and got the authorization_code and use it in the above code but got the error.

Someone help me out please...Really have no idea...

Member Updates

Hi I created this function for LinkedinApplication object similar to Javascript API's Member Updates, based on get_network_updates(). Hope you find it useful

def get_member_updates(self, types, linkedin_id, self_scope=True, params=None, headers=None):
    url = '%s/%s/network/updates' % (ENDPOINTS.PEOPLE, linkedin_id)
    if not params:
        params = {}

    if types:
        params.update({'type': types})

    if self_scope is True:
        params.update({'scope': 'self'})

    try:
        response = self.make_request('GET', url, params=params, headers=headers)
        response = response.json()
    except requests.ConnectionError as error:
        raise LinkedInHTTPError(error.message)
    else:
        if not self.request_succeeded(response):
            raise LinkedInError(response)
        return response

Support comment only shares

Linkedin allows a comment AND/OR content with the Share API. The way the client currently works the content variables are always present and LinkedIn validation requires values when they aren't needed. I was thinking of changing submit_share to something like the following. If the change is something you are interested in I'll submit a pull request.

    def submit_share(self, comment=None, title=None, description=None, submitted_url=None, submitted_image_url=None, visibility='anyone'):
        post = {
            'visibility': {
                'code': visibility,
            }
        }
        if comment is not None:
            post['comment'] = comment
        if submitted_url is not None:
            post['content'] = {
                'title': title,
                'submitted-url': submitted_url,
                'submitted-image-url': submitted_image_url,
                'description': description,
            }
        ...

SOLVED - Problem getting the Token/Authentication using the tutorial

I'm trying to make my Python/Flask web app authenticate using the python-linkedin API.
In the tutorial a redirection is assumed:
"When you grant access to the application, you will be redirected to the return url with the following query strings appended to your RETURN_URL:"

So, basically I'm running my server online and checking if the GET request to my return URL have query strings(code and state).
So if I just try to access the address - http://winterfell-django-1-90354.euw1.nitrousbox.com:4000/ - I will perform the authentication.
After that, I redirection to my return URL (http://winterfell-django-1-90354.euw1.nitrousbox.com:4000/) is expected, but it doesn't happen.

Here is my code:

from linkedin import linkedin
import json
import csv
from flask import Flask , jsonify, abort, make_response, request, url_for

CONSTANTS

API_KEY = '77wcgvnmv1jywx'
API_SECRET = 'PPIzXGAPX1eEAa55'
RETURN_URL = 'http://winterfell-django-1-90354.euw1.nitrousbox.com:4000/'

app = Flask(name)
@app.route('/', methods = ['GET'])
def get_authentication():
global code
global state
if ((request.args.get('code')) and (request.args.get('state'))):
code = request.args.get('code')
state = request.args.get('state')
else:
authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
application = linkedin.LinkedInApplication(authentication)

print authentication.authorization_url
print(code)
print(state)
return 'Code: ' + code + ' | State: ' + state

I'm only using GET verbs, don't know if that's the problem.

LinkedInHTTPError - 401 Client Error: Unauthorized

I've just 'discovered' your python-linkedin library earlier today and set it up and tried to make it work with Django.
But as soon as I set the authorization-code and want to retrieve the access-token with it, I get an LinkedInHTTPError : 401 Client Error: Unauthorized.

Here's my code; I'm using two views, one that redirects to the LinkedIn authorization page, and one for the return-url:

from django.shortcuts import render, render_to_response, redirect
from django.http import HttpResponse

from linkedin import linkedin


LI_API_KEY="123abc"
LI_API_SECRET="xyz123"
LI_RETURN_URL = 'http://127.0.0.1:8000/skills/linkedin-authcode/'


def signup(request):

    # Instantiate the developer authentication class
    authentication = linkedin.LinkedInAuthentication(LI_API_KEY, LI_API_KEY,
                                                     LI_RETURN_URL, linkedin.PERMISSIONS.enums.values())
    return redirect( authentication.authorization_url )



def linkedin_authcode(request):

    auth_code = request.GET.get('code', None)
    state = request.GET.get('state', None)

    authentication = linkedin.LinkedInAuthentication(LI_API_KEY, LI_API_KEY,
                                                     LI_RETURN_URL, linkedin.PERMISSIONS.enums.values())
    authentication.authorization_code = auth_code
    access_token = authentication.get_access_token()
    print access_token

    return HttpResponse("Linked Auth Code return page")

The debug-data I receive is:

Request Method: GET
Request URL: http://127.0.0.1:8000/skills/linkedin-authcode/?code=AQRandalotmore&state=4d64f8aa4b79a1fab3a73909a46bc322
Django Version: 1.6.2
Exception Type: LinkedInHTTPError
Exception Value:
401 Client Error: Unauthorized
Exception Location: /Library/Python/2.7/site-packages/linkedin/linkedin.py in get_access_token, line 123
Python Executable: /usr/bin/python
Python Version: 2.7.5
Python Path:
['/Users/planetcrypton/Sites/coworkerdev',
'/Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
Server time: Wed, 7 May 2014 12:54:23 +0000

More visibility for project on Ohloh?

Hello,

More and more when I have the question "which community is most active" when comparing open source efforts I am using Ohloh.net

To that end I noticed that this python-linkedin project is not yet on there and I'd like to add it to my personal list in order to give this project more visibility. Would you be up for adding this project there as the "owner"?

Developer Authentication

Hi .. has developer authentication been removed by LinkedIn? I noticed today I had a number of failing calls with OAUTH errors and I went to check my developer keys and there is now no option to refresh them.

Has this been removed or is it now only available for partners?

If so might be good to add a note to the page documentation here or remove the developer authentication notes and endpoint.

Cannot submit share with only a comment and an image

If you want to submit a share that is only a comment and an image then the submit fails with a keyerror.

In the function submit_company_share the following code exists:

        if title is not None and submitted_url is not None:
            post['content'] = {
                'title': title,
                'submitted-url': submitted_url,
                'description': description,
            }
        if submitted_image_url:
            post['content']['submitted-image-url'] = submitted_image_url

content is only created if there is a title and a url. In this case trying to add an image url will cause the keyerror on content.

Is this by design? Does linkedin not allow for only a comment and an image?

The documentation at https://developer.linkedin.com/docs/company-pages#company_share does not prohibit the ability to only include the image_url in the content.

Thanks.

Trying to get a user profile using public URL - LinkedInError: 400 Client Error: Bad Request

I'm not managing to get the results from a profile using it's URL.

Basically I'm trying to use that request:
application.get_profile(member_url='http://www.linkedin.com/profile/view?id=238343623&authType=name&authToken=LMsx&trk=api*a3334503*s3406633*')

I also tried to use only:
application.get_profile(member_url='http://www.linkedin.com/profile/view?id=238343623')

Didn't work either, same error

Everything is working, I get a response using no parameters or the 'user id' as parameter, but I need to use the 'user public URL' to my searches.

Best Regards
Michel

TypeError: None object cannot be quoted

When i execute the "http_api.py" i am getting the following error.The error is like this

$ python http_api.py
Server started on port: 8080

127.0.0.1 - - [05/Feb/2015 11:56:14] "GET / HTTP/1.1" 200 -

Exception happened during processing of request from ('127.0.0.1', 49805)
Traceback (most recent call last):
File "D:\Python27\Lib\SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "D:\Python27\Lib\SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\Python27\Lib\SocketServer.py", line 649, in init
self.handle()
File "D:\Python27\Lib\BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "D:\Python27\Lib\BaseHTTPServer.py", line 328, in handle_one_request
method()
File "http_api.py", line 57, in do_GET
print liw.authentication.authorization_url
File "c:\Users\BITON-G510\Desktop\XMPP_ENV\lib\site-packages\linkedin\linkedin.py", line 96, in authorization_url
qsl = ['%s=%s' % (urllib.quote(k), urllib.quote(v)) for k, v in qd.items()]
File "D:\Python27\Lib\urllib.py", line 1269, in quote
raise TypeError('None object cannot be quoted')
TypeError: None object cannot be quoted.

What is the mistake i am doing..?

PyPi version is broken .. missing readme.rst

gives the following error on pip install .. and readme.rst is missing from the download on the pypi site.

Downloading/unpacking python-linkedin
Downloading python-linkedin-3.0.tar.gz
Running setup.py egg_info for package python-linkedin
Traceback (most recent call last):
File "", line 16, in
File "/djangoenv/build/python-linkedin/setup.py", line 12, in
with open(os.path.join(os.path.dirname(file), 'README.rst')) as readme:
IOError: [Errno 2] No such file or directory: '/djangoenv/build/python-linkedin/README.rst'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 16, in

File "/djangoenv/build/python-linkedin/setup.py", line 12, in

with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:

IOError: [Errno 2] No such file or directory: '/djangoenv/build/python-linkedin/README.rst'

400 Client Error: Bad Request on get_access_token

Hi,

I'm trying to use your library however I'm getting error when I call get_access_token.

After getting authorization_code, I'm calling:
authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
authentication.authorization_code = '?????????'
authentication.get_access_token()

This throw an exception:
Traceback (most recent call last):
File "teste.py", line 12, in
authentication.get_access_token()
File "/usr/local/lib/python2.7/dist-packages/python_linkedin-2.0-py2.7.egg/linkedin/linkedin.py", line 96, in get_access_token
raise LinkedInHTTPError(error.message)
linkedin.exceptions.LinkedInHTTPError: 400 Client Error: Bad Request

Linkedin Authentication - Cannot connect to proxy. Socket error: Tunnel connection failed: 403 Forbidden.

Hi,

I was having trouble getting linkedin authentication process working and have been getting the following error:

<class 'requests.exceptions.ProxyError'> Cannot connect to proxy. Socket error: Tunnel connection failed: 403 Forbidden.

The error occurs when I try and call: authentication.get_access_token(). Code below.

I'm not sure if this is useful but I'm running the code via pythonanywhere.com using the web2py framework.

Any help would be great!

Thanks,

Viv


from linkedin import linkedin
import urlparse

def linkedin_setup():

# Define CONSUMER_KEY, CONSUMER_SECRET
CONSUMER_KEY = '______'
CONSUMER_SECRET = '___________'

# RETURN_URL from the credentials
RETURN_URL = "____________"

# Check current URL to see if if the URL has the 'code' variable from linkedin
current_url = URL(args=request.args, vars=request.get_vars, host=True)
parsed = urlparse.urlparse(current_url)
URL_dict = urlparse.parse_qs(parsed.query)

authentication = linkedin.LinkedInAuthentication(CONSUMER_KEY, CONSUMER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())

# if code variable exists then get token
if 'code' in URL_dict:
    authentication.authorization_code = urlparse.parse_qs(parsed.query)['code']
    authentication.get_access_token()
else:
    application = linkedin.LinkedInApplication(authentication)
    redirect(authentication.authorization_url)  # open this url on your browser

Using this lib from PHP code

Hi, I have to maintain legacy PHP code, which has a problem as described in this SO thread:
http://stackoverflow.com/questions/21811385/php-oauth-removes-the-location-from-the-received-headers

I would like to run the following script using the PHP exec command, after the user is already authenticated with LinkedIn using the PHP application but I get a 400 code.
Is there a way to debug this response:

PHP code:

$path = dirname(__FILE__) . '/group_share.py';
                $cmd ="python {$path} {$token} {$secret} {$app_token} {$app_secret} {$groupId} {$jobPostBody} 2>&1";
                $tmp = exec($cmd,$output);
                print_r($output);
                exit(1);

Python script

#@description python implementation for linkedin groups share
#@param argv[1] user token
#@param argv[2] user secret
#@param argv[3] app token
#@param argv[4] app secret
#@param argv[5] group id
#@param argv[6] post body
#@param argv[7] return url
import sys
from linkedin import linkedin

USER_TOKEN = sys. argv[1]
USER_SECRET = sys. argv[2]
CONSUMER_KEY = sys.argv[3]
CONSUMER_SECRET = sys.argv[4]
RETURN_URL = sys.argv[7] or None
REQUEST_BODY = sys.argv[6]
RESOURCE = 'http://api.linkedin.com/v1/groups/' + sys.argv[5] + '/posts'

auth = linkedin.LinkedInDeveloperAuthentication(CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())

app = linkedin.LinkedInApplication(auth)

post_response = app.make_request('POST', RESOURCE, REQUEST_BODY)

print post_response

Output is:

Array ( [0] => {'cookies': <[Cookie(version=0, name='lidc', value='"b=VB22:g=44:u=1:i=1392635829:t=1392722220:s=213364215"', port=None, port_specified=False, domain='.linkedin.com', domain_specified=True, domain_initial_dot=True, path='/', path_specified=True, secure=False, expires=1392722220, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False)]>, '_content': '{\n "errorCode": 0,\n "message": "Couldn\'t parse Json body: Unexpected character (\'t\' (code 116)): was expecting double-quote to start field name\\n at [Source: java.io.StringReader@10487452; line: 1, column: 3]",\n "requestId": "TVUOCOQ8PD",\n "status": 400,\n "timestamp": 1392716020952\n}', 'headers': CaseInsensitiveDict({'x-li-pop': 'PROD-ELA4', 'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'set-cookie': 'lidc="b=VB22:g=44:u=1:i=1392635829:t=1392722220:s=213364215"; Expires=Tue, 18 Feb 2014 11:17:00 GMT; domain=.linkedin.com; Path=/', 'vary': '*', 'x-li-uuid': 'ONpKjNfrUxPQ45sf0CoAAA==', 'server': 'Apache-Coyote/1.1', 'x-li-fabric': 'prod-lva1', 'connection': 'keep-alive', 'date': 'Tue, 18 Feb 2014 09:33:40 GMT', 'x-li-request-id': 'TVUOCOQ8PD', 'x-li-format': 'json', 'content-type': 'application/json;charset=UTF-8'}), 'url': u'http://api.linkedin.com/v1/groups/4896198/posts', 'status_code': 400, '_content_consumed': True, 'encoding': 'UTF-8', 'request': , 'connection': , 'elapsed': datetime.timedelta(0, 0, 682628), 'raw': , 'reason': 'Bad Request', 'history': []} )

"Legacy App" working with OAuth but new app not working with OAuth

I am finding a peculiar thing when using this library that I think may reflect an important bug, and I'd like your thoughts on it.

When I follow the OAuth flow with the "API Key" and "API Secret" from an app I created a couple of years ago (what I will call app1) and plug them into the flow as what you describe in the README.md as "application key" and "application secret", everything works fine. An important detail here is that the length and form of my API Key/Secret values resemble the same ones you use in the README.md as well.

However, when I create a new app (what I will call app2), I see that I now have an "API Key" a "Secret Key" as well as an "OAuth User Token" and "OAuth User Secret". The length/form of these values do not resemble at all my API Key/Secret from app1 (nor do they resemble your values from the README.md.) Regardless of which combination of these values that I use, the OAuth flow always results in a 401 error.

I am curious if you might be testing this library with values from an app you created long ago as opposed to an app recently and, thus, experiencing the same troubles that I am? Intuition suggests that this is the case.

I would be very interested in hearing back from you on this if you could create a brand new app and test, and seeing an update to the README that clarifies the language a bit and includes updated sample app values that work as-is.

This is currently blocking me, and I'm not quite sure how to proceed without getting down into the guts of the linkedin.py file. Are you able to assist?

OAuth issue

Hello!

I'm getting
LinkedInError: Request Error: [unauthorized]. No consumer found for key when trying to authorise. The token is valid as I am able to make API requests with http://developer.linkedinlabs.com/oauth-test/

auth = linkedin.LinkedInDeveloperAuthentication(CONSUMER_KEY, CONSUMER_SECRET, 
                                USER_TOKEN, USER_SECRET, 
                                RETURN_URL, 
                                permissions=linkedin.PERMISSIONS.enums.values())

app = linkedin.LinkedInApplication(auth)

app.get_profile()

facet search in people search api

Hi,

Thank you for the great lib, works fine.

I am looking for an example on how to use facets in the people search api

application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params=p)

I have tried the following for p:
p={}
p['keywords'] = 'datamining'
p['countryCode'] = 'nl'
p['facet'] = 'location,nl:0'
p['company-name'] = 'netwerk%20vsp'
p['current-company'] = 'true'
p['sort'] = 'connections'
p['sort'] = 'recommenders'
p['facets'] = 'Industry,Network'
p['facet'] = 'industry,41' # no effect no error
p['facet'] = 'network,F' # no efect no error

get_job does not apply selectors

function get_job() does not apply provided selectors.

only need to add following lines after line 437:
if selectors:
url = '%s:(%s)' % (url, LinkedInSelector.parse(selectors))

Bug in make_request

Hi, it seems that there's a wrong line in make_request in LinkedInApplication.
The line: params = {} overwrites the method argument.

Can not get status updates

d = application.get_company_updates(1035, params={'count': 26})
print d['_count']

It only returns 10, not 26.

Syntax error

Traceback (most recent call last):
File "link-api.py", line 1, in <module>
from linkedin import linkedin
File "/home/leo_g/python-linkenin/venv/lib/python3.4/site-packages/linkedin/linkedin.py", line 294
except (requests.ConnectionError, requests.HTTPError), error:

I get the above error during installation and while trying to execute code.

I am using python3 on centos 7,

any help is apreciated

Getting error while using get_job() function of Job Look up API

I have got authorization for Job Look Up API and Job Search API. The function for Job Search API works. But when I was trying to get information for a specific job, I used the following code and got the error below:

application.get_job(job_id=27576874)

raise LinkedInError(message)
linkedin.exceptions.LinkedInError: 400 Client Error: Bad Request: Unknown Error

Hope some one can help, thanks!

The PyPI version is out of date.

Please publish the newest version of this library on PyPI so that the version on PyPI is compatible with the current documentation.

Params 'modified-since' is ignored ?

First of all, thanks for sharing the library. It was great connecting with LinkedIn.

I have one issue with connection object.
conns = application.get_connections(
selectors=['id','first-name', 'last-name','headline','industry'],
params={ 'modified':'updated','modified-since': epoch }
)

It seems that modified-since parameter is ignored. No matter what date timestamp I passed as parameters, it always return all connections.

Did I missing something ? Thanks in advance.

Client ID and Client Secret

according to this

authentication = linkedin.LinkedInDeveloperAuthentication(CONSUMER_KEY, CONSUMER_SECRET,
USER_TOKEN, USER_SECRET,
RETURN_URL, linkedin.PERMISSIONS.enums.values())

I need more information

but here:
https://www.linkedin.com/developer/apps/

I can only get Client ID and Client Secret.

How and where do I find CONSUMER_KEY, CONSUMER_SECRET,
USER_TOKEN, USER_SECRET, ?

Thanks a lot

Leave older versions of the module on PyPI when new versions are released

Can you please leave older versions of the module on PyPI when you release new versions?

It breaks existing workflows when a module is in a pip requirements file against a specific tested version and then disappears. Here's a case in point [1]. I appreciate the work on additional versions, but it will take me some time to re-test and bump dependencies. Leaving the older versions available as an option would be a great service to people such as myself. Thank you for your consideration.

[1] http://pastebin.com/Zg06N2kJ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.