quote_from_bytes() expected bytes
- Firstly, the package on Pypi doesn't work, but of course the version on Github can work.
- 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
TypeError: quote_from_bytes() expected bytes
Wish your help
This is happening because an older version is pushing bytes, I have fixed this by changes in the linked.py file.
Change line 109 in linkedin.py:
for k, v in list(qd.items()): qsl.append('%s=%s' % (quote(k), quote(v))) return self.AUTHORIZATION_URL, '&'.join(qsl)
hi, I modify the codes and provide a thrid party based authentication app by using my insights about django auth. I will share with you later. I think this version could help more people to use ur app. because they can use in this way
@linked_grant_require your view function
2015-11-29 23:15 GMT-05:00 Marshall Humble [email protected]:
This is happening because an older version is pushing bytes, I have fixed this by changes in the linked.py file.
Change line 109 in linkedin.py:
for k, v in list(qd.items()): qsl.append('%s=%s' % (quote(k), quote(v))) return self.AUTHORIZATION_URL, '&'.join(qsl)
— Reply to this email directly or view it on GitHub https://github.com/ozgur/python-linkedin/issues/90#issuecomment-160512264 .
Great, I'd love to see the authentication method you are using. I am running into an issue with step 3 on auth now with linkedin.
Here is the current version I used, please check doc shared with you linked_in 3.zip https://drive.google.com/file/d/0BxbR2jt9XyxtaWNFblkydkg2OHM/view?usp=drive_web .
I haven't submit pull request yet. (examination pending sadly $_$). But I will try to do it soon unless you can do it soon. Several modified version of your linkedin api will be provided after my examination. For this django support, you just refer to my two main code: in_profile.auth.backend % auth controlling in_profile.auth.decorator % session controlling, redirect, trigger python-linkedin api, add api entry to authorised users.
View.LinkedinProfileView gives you an example how to use it.
third_party.ajax and relevant js files provide a valid login utility for session environment testing support.
Wish these could help you for your further design of the api!
Regards, Lei Wang
2015-11-29 23:37 GMT-05:00 Marshall Humble [email protected]:
Great, I'd love to see the authentication method you are using. I am running into an issue with step 3 on auth now with linkedin.
— Reply to this email directly or view it on GitHub https://github.com/ozgur/python-linkedin/issues/90#issuecomment-160513898 .
Hi,Ozgur: Have you received my attached doc (pdf) ?
Regards, Lei Wang
2015-12-02 13:55 GMT-05:00 Yiak Wang Yi [email protected]:
Here is the current version I used, please check doc shared with you linked_in 3.zip https://drive.google.com/file/d/0BxbR2jt9XyxtaWNFblkydkg2OHM/view?usp=drive_web .
I haven't submit pull request yet. (examination pending sadly $_$). But I will try to do it soon unless you can do it soon. Several modified version of your linkedin api will be provided after my examination. For this django support, you just refer to my two main code: in_profile.auth.backend % auth controlling in_profile.auth.decorator % session controlling, redirect, trigger python-linkedin api, add api entry to authorised users.
View.LinkedinProfileView gives you an example how to use it.
third_party.ajax and relevant js files provide a valid login utility for session environment testing support.
Wish these could help you for your further design of the api!
Regards, Lei Wang
2015-11-29 23:37 GMT-05:00 Marshall Humble [email protected]:
Great, I'd love to see the authentication method you are using. I am running into an issue with step 3 on auth now with linkedin.
— Reply to this email directly or view it on GitHub https://github.com/ozgur/python-linkedin/issues/90#issuecomment-160513898 .
HI Lei, I got the file and I will look over it this weekend, (but I'm not Ozgur :)) Thanks for sending it!
Ok, no problem
2015-12-03 10:45 GMT-05:00 Marshall Humble [email protected]:
HI Lei, I got the file and I will look over it this weekend, (but I'm not Ozgur :)) Thanks for sending it!
— Reply to this email directly or view it on GitHub https://github.com/ozgur/python-linkedin/issues/90#issuecomment-161681855 .
Hi all, I'm still getting the same error. Checked linkedin.py and seems like it is not fixed.
Exception happened during processing of request from ('127.0.0.1', 50092)
Traceback (most recent call last):
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/socketserver.py", line 628, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/socketserver.py", line 684, in init
self.handle()
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/http/server.py", line 415, in handle
self.handle_one_request()
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/http/server.py", line 403, in handle_one_request
method()
File "http_api.py", line 62, in do_GET
open_new_tab(liw.authentication.authorization_url)
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/site-packages/python_linkedin-4.2-py3.5.egg/linkedin/linkedin.py", line 101, in authorization_url
qsl = ['%s=%s' % (quote(k), quote(v)) for k, v in qd.items()]
File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/site-packages/python_linkedin-4.2-py3.5.egg/linkedin/linkedin.py", line 101, in
TypeError: quote_from_bytes() expected bytes
@marshallhumble i tried your fix and it didnt work either.
Server started on port:8080
127.0.0.1 - - [26/Dec/2015 19:50:50] "GET / HTTP/1.1" 200 -
Exception happened during processing of request from ('127.0.0.1', 50722) Traceback (most recent call last): File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/socketserver.py", line 628, in process_request_thread self.finish_request(request, client_address) File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/socketserver.py", line 357, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/socketserver.py", line 684, in init self.handle() File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/http/server.py", line 415, in handle self.handle_one_request() File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/http/server.py", line 403, in handle_one_request method() File "http_api.py", line 61, in do_GET open_new_tab(liw.authentication.authorization_url) File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/site-packages/python_linkedin-4.2-py3.5.egg/linkedin/linkedin.py", line 109, in authorization_url qsl.append('%s=%s' % (quote(k), quote(v))) File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/urllib/parse.py", line 712, in quote return quote_from_bytes(string, safe) File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/urllib/parse.py", line 737, in quote_from_bytes raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes
just comment out some linkedin services ^_^ new api has disabled several services if u are not in partner programme
Hello @yiakwy I want to run this python-linkedin in my pyramid project. How do i do that. I am also getting same issue as TypeError: quote_from_bytes() expected bytes Please help.
@pinkeshdarji Hi, first of the first, You need to keep an eye on recent update of linkedin api. What I did before (one year ago) is to change it according to the latest version of Linkedin api. What was the change of api then? Linkedin announced to terminate supports for customer, company apis and so on. That means that only permitted partners who pass to be involved with partnership programme with linkedin could access tho those apis. so you need to mute some api entries wroted by ozgur. You can refer to the codes I provided. If it didn't work, you might as well go back to Linkedin Doc to see neweast updates. Hope this helps!
For me this helped:
Changing the def authorization_url(self) function in the linkedin.py file:
def authorization_url(self):
qd = {'response_type': 'code',
'client_id': self.key,
'scope': (' '.join(self.permissions)).strip(),
'state': self.state or self._make_new_state(),
'redirect_uri': self.redirect_uri}
# urlencode uses quote_plus when encoding the query string so,
# we ought to be encoding the qs by on our own.
#qsl = ['%s=%s' % (str(quote(k)), str(quote(v))) for k, v in qd.items()]
qsl = []
for k, v in list(qd.items()):
qsl.append('%s=%s' % (quote(str(k)), quote(str(v))))
return '%s?%s' % (self.AUTHORIZATION_URL, '&'.join(qsl))