Skip to content

About connection failure to multiple Watson services #123

@Enchanman

Description

@Enchanman

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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions