IBM / python-sdk-core

The python-sdk-core repository contains core functionality required by Python code generated by the IBM OpenAPI SDK Generator.
Apache License 2.0
20 stars 27 forks source link

About connection failure to multiple Watson services #123

Closed Enchanman closed 3 years ago

Enchanman commented 3 years ago

I'm sorry for my poor English. May I ask you a question

It seems that the authentication process has changed in version 3.11.0, but in applications that connect to multiple Watson services, it worked normally in versions earlier than version 3.11.0, but since 3.11.0 When upgrading to, a 403 error is now returned.

When I created and checked the program code for verification, it seems that the cause is that the content of request_payload of token_manager held in the instance object of watson service is rewritten to API KEY of the second NLC (nlc_2). Is it a bug? Or is it a specification? Please let me know if there is any mistake in how to use it.

The program code when I verified it is as follows. Thank you.

from ibm_watson import NaturalLanguageClassifierV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

apikey = 'e1R7Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
endpoint = 'https://api.jp-tok.natural-language-classifier.watson.cloud.ibm.com/instances/2a0b44ac-xxxxxxxxxxxxxxxxxxxxxxxxx'

apikey2 = 'VXrE7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
endpoint2 = 'https://api.jp-tok.natural-language-classifier.watson.cloud.ibm.com/instances/aedd905d-xxxxxxxxxxxxxxxxxxxxxxxxx'

nlc_1_auth = IAMAuthenticator(apikey)
nlc_1 = NaturalLanguageClassifierV1(authenticator=nlc_1_auth)
nlc_1.set_service_url(endpoint)

nlc_2_auth = IAMAuthenticator(apikey2)
nlc_2 = NaturalLanguageClassifierV1(authenticator=nlc_2_auth)
nlc_2.set_service_url(endpoint2)

classifiers = nlc_1.list_classifiers()    # <---- 403 Error returned
print(classifiers)

classifiers = nlc_2.list_classifiers()
print(classifiers)
padamstx commented 3 years ago

@pyrooka Could you please take a look at this?

padamstx commented 3 years ago

It might aid problem determination if you could help by doing a couple of experiments:

  1. Could you temporarily modify your test code above so that you comment out the use of the second authenticator and service instance? In other words, restrict your test to only the first authenticator and service instance.
  2. Could you retry your test program using version 3.10.1 of the python core library?

Thank you for any help you can provide in the investigation of the problem.

Edit: @Enchanman please disregard the requests for experimentation above. We have diagnosed the problem and are working on a fix.

Enchanman commented 3 years ago

@padamstx Hello, Thank you for your reply.

  1. Could you temporarily modify your test code above so that you comment out the use of the second authenticator and service instance? In other words, restrict your test to only the first authenticator and service instance.

    --> I commented out the second authentication and service instance and ran it, and I got the list of classifiers successfully.

  2. Could you retry your test program using version 3.10.1 of the python core library?

    --> When I reverted the version to 3.10.1 and ran it, I was able to get the list of classifiers successfully for both the first and second.

please disregard the requests for experimentation above. We have diagnosed the problem and are working on a fix.

Thank you for your prompt response!

padamstx commented 3 years ago

@Enchanman, thank you for doing the experiments above. Your results match our diagnosis so we seem to be on the right track for fixing the problem. Should be able to deliver a fix a bit later today.

ibm-devx-sdk commented 3 years ago

:tada: This issue has been resolved in version 3.11.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

padamstx commented 3 years ago

@Enchanman, could you please re-try your scenario using version 3.11.3 ?

Enchanman commented 3 years ago

@padamstx Hi, I updated the version to 3.11.3 and checked it, and it worked fine. Thank you for your support.

padamstx commented 3 years ago

I updated the version to 3.11.3 and checked it, and it worked fine. Thank you for your support.

@Enchanman And thank YOU for finding and reporting this bug. It was a very subtle bug that slipped through our testing, but we have added some tests to ensure this doesn't happen again in the future.