Skip to content

Commit

Permalink
Merge pull request #14 from haodeqi/authentication
Browse files Browse the repository at this point in the history
chore: update authentication method and requirements
  • Loading branch information
mingtan888 authored Oct 9, 2019
2 parents 10709a3 + 020222a commit fb3a89f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Semantic versioning
# MAJOR.MINOR.PATCH

__version__ = '1.0.0'
__version__ = '1.0.1'
2 changes: 1 addition & 1 deletion assistant_dialog_skill_analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.0.1'
29 changes: 8 additions & 21 deletions assistant_dialog_skill_analysis/utils/skills_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from nbconvert.preprocessors import ExecutePreprocessor
import nltk
import ibm_watson
from ibm_cloud_sdk_core.authenticators import \
IAMAuthenticator, BasicAuthenticator, NoAuthAuthenticator

DEFAULT_API_VERSION = '2019-02-28'
DEFAULT_PROD_URL = 'https://gateway.watsonplatform.net/assistant/api'
Expand Down Expand Up @@ -113,30 +115,15 @@ def retrieve_workspace(iam_apikey=None,
:param export_flag:
:return workspace: workspace json
"""
conversation = None

if iam_apikey:
if url == "https://gateway-s.watsonplatform.net/assistant/api":
conversation = ibm_watson.AssistantV1(iam_apikey=iam_apikey,
url=url,
iam_url=STAGE_IAM_URL,
version=api_version)
else:
conversation = ibm_watson.AssistantV1(iam_apikey=iam_apikey,
url=url,
version=api_version)
authenticator = IAMAuthenticator(apikey=iam_apikey)
elif username and password:
if url == "https://gateway-s.watsonplatform.net/assistant/api":
conversation = ibm_watson.AssistantV1(username=username,
password=password,
url=url,
iam_url=STAGE_IAM_URL,
version=api_version)
else:
conversation = ibm_watson.AssistantV1(username=username,
password=password,
url=url,
version=api_version)
authenticator = BasicAuthenticator(username=username, password=password)
else:
authenticator = NoAuthAuthenticator()

conversation = ibm_watson.AssistantV1(authenticator=authenticator, version=api_version)

if export_flag:
ws_json = conversation.get_workspace(workspace_id, export=export_flag)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ tabulate
matplotlib
nltk
seaborn
ibm-watson>=3.2.0
ibm-watson==4.0.1
scipy>=1.2.0
jupyter

0 comments on commit fb3a89f

Please sign in to comment.