Closed xiapoy closed 8 years ago
Hi @naileakim, thank you for reporting the issue. I'm looking into it.
Hi @Alien1993,
Thanks for your reply, here are some updates that may help you solving the issue:
I am using mkmsdk 0.4.0
and python 2.7.12
. You can find the complete log below:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-f74469a900d2> in <module>()
----> 1 account = mkm.account_management.account()
/usr/local/lib/python2.7/site-packages/mkmsdk/mkm.pyc in __call__(self, *args, **kwargs)
46
47 resolver = resolvers.SimpleResolver(self.sandbox_mode)
---> 48 return resolver.resolve(api_map=self.api_map, **kwargs)
49
50 mkm = Mkm(api_map=default_api_map)
/usr/local/lib/python2.7/site-packages/mkmsdk/resolvers.pyc in resolve(self, api_map, data, **kwargs)
59 data = serializer.serialize(data=data)
60
---> 61 return self.api.request(url=self.url, method=self.method, data=data)
/usr/local/lib/python2.7/site-packages/mkmsdk/api.pyc in request(self, url, method, **kwargs)
40 auth = self.create_auth(complete_url)
41
---> 42 response = request(method=method, url=complete_url, auth=auth, **kwargs)
43 return self.handle_response(response)
44
/usr/local/lib/python2.7/site-packages/requests/api.pyc in request(method, url, **kwargs)
54 # cases, and look like a memory leak in others.
55 with sessions.Session() as session:
---> 56 return session.request(method=method, url=url, **kwargs)
57
58
/usr/local/lib/python2.7/site-packages/requests/sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
459 hooks = hooks,
460 )
--> 461 prep = self.prepare_request(req)
462
463 proxies = proxies or {}
/usr/local/lib/python2.7/site-packages/requests/sessions.pyc in prepare_request(self, request)
392 auth=merge_setting(auth, self.auth),
393 cookies=merged_cookies,
--> 394 hooks=merge_hooks(request.hooks, self.hooks),
395 )
396 return p
/usr/local/lib/python2.7/site-packages/requests/models.pyc in prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
296 self.prepare_cookies(cookies)
297 self.prepare_body(data, files, json)
--> 298 self.prepare_auth(auth, url)
299
300 # Note that prepare_auth must be last to enable authentication schemes
/usr/local/lib/python2.7/site-packages/requests/models.pyc in prepare_auth(self, auth, url)
498
499 # Allow auth to make its changes.
--> 500 r = auth(self)
501
502 # Update self to reflect the auth changes.
/usr/local/lib/python2.7/site-packages/mkmsdk/MKMOAuth1.pyc in __call__(self, r)
10
11 def __call__(self, r):
---> 12 r = super(MKMOAuth1, self).__call__(r)
13
14 r.prepare_headers(r.headers)
/usr/local/lib/python2.7/site-packages/requests_oauthlib/oauth1_auth.pyc in __call__(self, r)
86 # Omit body data in the signing of non form-encoded requests
87 r.url, headers, _ = self.client.sign(
---> 88 unicode(r.url), unicode(r.method), None, r.headers)
89
90 r.prepare_headers(headers)
/usr/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.pyc in sign(self, uri, http_method, body, headers, realm)
311 # generate the signature
312 request.oauth_params.append(
--> 313 ('oauth_signature', self.get_oauth_signature(request)))
314
315 # render the signed request and return it
/usr/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.pyc in get_oauth_signature(self, request)
126 self.resource_owner_secret)
127
--> 128 uri, headers, body = self._render(request)
129
130 collected_params = signature.collect_parameters(
/usr/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.pyc in _render(self, request, formencode, realm)
208 if self.signature_type == SIGNATURE_TYPE_AUTH_HEADER:
209 headers = parameters.prepare_headers(
--> 210 request.oauth_params, request.headers, realm=realm)
211 elif self.signature_type == SIGNATURE_TYPE_BODY and request.decoded_body is not None:
212 body = parameters.prepare_form_encoded_body(
/usr/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/utils.pyc in wrapper(params, *args, **kwargs)
29 def wrapper(params, *args, **kwargs):
30 params = filter_oauth_params(params)
---> 31 return target(params, *args, **kwargs)
32
33 wrapper.__doc__ = target.__doc__
/usr/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/parameters.pyc in prepare_headers(oauth_params, headers, realm)
54 #
55 # .. _`Section 3.6`: http://tools.ietf.org/html/rfc5849#section-3.6
---> 56 escaped_name = utils.escape(oauth_parameter_name)
57 escaped_value = utils.escape(value)
58
/usr/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/utils.pyc in escape(u)
54 if not isinstance(u, unicode_type):
55 raise ValueError('Only unicode objects are escapable. ' +
---> 56 'Got %s of type %s.' % (u, type(u)))
57 # Letters, digits, and the characters '_.-' are already treated as safe
58 # by urllib.quote(). We need to add '~' to fully support rfc5849.
ValueError: Only unicode objects are escapable. Got oauth_token of type <type 'str'>.
And finally, a quote from OAuthLib FAQ:
What does ValueError Only unicode objects are escapable. Got one of type X. mean?
OAuthLib uses unicode everywhere and when creating a OAuth 1 signature a number of parameters need to be percent encoded (aka escaped). At least one parameter could not be encoded. Usually because None or a non UTF-8 encoded string was supplied.
Let me know if you need any other information
@naileakim I've fixed the issue and released a new version. Update to 0.4.1 and you're ready to go.
Thank you again for reporting the issue. :smile:
Thanks that's awesome, I upgraded to version 0.4.1.
Unfortunately I still get an error, this time about connection:
ConnectionError: Request failed
Status code: 401
Response message: Unauthorized
That looks like issue #2
What call are you making when getting that error?
I was calling mkm.account_management
. I just figured out that other calls likemkm.market_place
are working now 😊
I guess it's because a widget app has only access to non-personal information.
Thanks for your great help!
Good to know everything it's working correctly. 👍
Hi, I get this error while trying to use my widget app:
My .bash_profile looks like this:
Also thanks for this great package 🙂