watson-developer-cloud/python-sdk

https://cloud.ibm.com/apidocs/natural-language-understanding?code=python#introduction

Lpourchot opened this issue · 5 comments

Remember, an issue is not the place to ask questions. If you have issues with the APIs or have a question about the Watson services, see Stack Overflow.

Before you open an issue, please check if a similar issue already exists or has been closed before.

Check service status

  1. For service issues or 5xx errors, first, go to the IBM Cloud status page and check the status of the service.
  2. If the service status is OK, continue with a bug report.

Overview
Error when running python code proposed as example, error raised :"It is required that you pass in a value for the "algorithms" argument when calling decode()."

Expected behavior
no error raised when running an example proposed, without any change in the code

Actual behavior
error, script stopped.

How to reproduce
Help us to reproduce what you experienced. Include your code snippets (without credentials)

Screenshots

DecodeError Traceback (most recent call last)
in
----> 1 nlu.analyze(text='this is my experimental text. Bruce Banner iis the Hulk and Bruce Wayne is BATMAN! Superman fears not Banner, but Wayne.',
2 features=Features(entities=EntitiesOptions(), keywords=KeywordsOptions())).get_result()

~\anaconda3\lib\site-packages\ibm_watson\natural_language_understanding_v1.py in analyze(self, features, text, html, url, clean, xpath, fallback_to_raw, return_analyzed_text, language, limit_text_characters, **kwargs)
176
177 url = '/v1/analyze'
--> 178 request = self.prepare_request(method='POST',
179 url=url,
180 headers=headers,

~\anaconda3\lib\site-packages\ibm_cloud_sdk_core\base_service.py in prepare_request(self, method, url, headers, params, data, files, **kwargs)
295 request['data'] = data
296
--> 297 self.authenticator.authenticate(request)
298
299 # Next, we need to process the 'files' argument to try to fill in

~\anaconda3\lib\site-packages\ibm_cloud_sdk_core\authenticators\iam_authenticator.py in authenticate(self, req)
104 """
105 headers = req.get('headers')
--> 106 bearer_token = self.token_manager.get_token()
107 headers['Authorization'] = 'Bearer {0}'.format(bearer_token)
108

~\anaconda3\lib\site-packages\ibm_cloud_sdk_core\jwt_token_manager.py in get_token(self)
77 """
78 if self._is_token_expired():
---> 79 self.paced_request_token()
80
81 if self._token_needs_refresh():

~\anaconda3\lib\site-packages\ibm_cloud_sdk_core\jwt_token_manager.py in paced_request_token(self)
122 if not request_active:
123 token_response = self.request_token()
--> 124 self._save_token_info(token_response)
125 self.request_time = 0
126 return

~\anaconda3\lib\site-packages\ibm_cloud_sdk_core\jwt_token_manager.py in _save_token_info(self, token_response)
189
190 # The time of expiration is found by decoding the JWT access token
--> 191 decoded_response = jwt.decode(access_token, verify=False)
192 # exp is the time of expire and iat is the time of token retrieval
193 exp = decoded_response.get('exp')

~\anaconda3\lib\site-packages\jwt\api_jwt.py in decode(self, jwt, key, algorithms, options, **kwargs)
111 **kwargs,
112 ) -> Dict[str, Any]:
--> 113 decoded = self.decode_complete(jwt, key, algorithms, options, **kwargs)
114 return decoded["payload"]
115

~\anaconda3\lib\site-packages\jwt\api_jwt.py in decode_complete(self, jwt, key, algorithms, options, **kwargs)
77
78 if options["verify_signature"] and not algorithms:
---> 79 raise DecodeError(
80 'It is required that you pass in a value for the "algorithms" argument when calling decode().'
81 )

DecodeError: It is required that you pass in a value for the "algorithms" argument when calling decode().

SDK Version
Please provide the SDK version here.

Additional information:

  • OS: windows10
  • Which version of Python are you using? 3.8

Additional context
Add any other details about the problem.

@Lpourchot thanks for opening the issue, can you please provide a code snippet of how you are using the SDK?

Hello, as mentioned in the API doc :https://cloud.ibm.com/apidocs/natural-language-understanding?code=python

!pip install --upgrade "ibm-watson>=5.0.0"

and get : Successfully installed ibm-cloud-sdk-core-1.7.3 ibm-watson-5.0.2

That does not give me all the info to debug though, can you confirm whether you replaced the API key properly and set the service URL?

Closing issue as stale. If this problem persists, we encourage you to either respond in this issue so we can reopen it or create a new issue.