@@ -33,20 +33,10 @@ public class ExampleLanguageTranslatorV3 : MonoBehaviour
3333 [ Tooltip ( "The version date with which you would like to use the service in the form YYYY-MM-DD." ) ]
3434 [ SerializeField ]
3535 private string _versionDate ;
36- [ Header ( "CF Authentication" ) ]
37- [ Tooltip ( "The authentication username." ) ]
38- [ SerializeField ]
39- private string _username ;
40- [ Tooltip ( "The authentication password." ) ]
41- [ SerializeField ]
42- private string _password ;
4336 [ Header ( "IAM Authentication" ) ]
4437 [ Tooltip ( "The IAM apikey." ) ]
4538 [ SerializeField ]
4639 private string _iamApikey ;
47- [ Tooltip ( "The IAM url used to authenticate the apikey (optional). This defaults to \" https://iam.bluemix.net/identity/token\" ." ) ]
48- [ SerializeField ]
49- private string _iamUrl ;
5040 #endregion
5141
5242 private string _pharseToTranslate = "Hello, welcome to IBM Watson!" ;
@@ -75,32 +65,25 @@ void Start()
7565
7666 private IEnumerator CreateService ( )
7767 {
78- // Create credential and instantiate service
79- Credentials credentials = null ;
80- if ( ! string . IsNullOrEmpty ( _username ) && ! string . IsNullOrEmpty ( _password ) )
81- {
82- // Authenticate using username and password
83- credentials = new Credentials ( _username , _password , _serviceUrl ) ;
84- }
85- else if ( ! string . IsNullOrEmpty ( _iamApikey ) )
68+ if ( string . IsNullOrEmpty ( _iamApikey ) )
8669 {
87- // Authenticate using iamApikey
88- TokenOptions tokenOptions = new TokenOptions ( )
89- {
90- IamApiKey = _iamApikey ,
91- IamUrl = _iamUrl
92- } ;
93-
94- credentials = new Credentials ( tokenOptions , _serviceUrl ) ;
95-
96- // Wait for tokendata
97- while ( ! credentials . HasIamTokenData ( ) )
98- yield return null ;
70+ throw new WatsonException ( "Plesae provide IAM ApiKey for the service." ) ;
9971 }
100- else
72+
73+ // Create credential and instantiate service
74+ Credentials credentials = null ;
75+
76+ // Authenticate using iamApikey
77+ TokenOptions tokenOptions = new TokenOptions ( )
10178 {
102- throw new WatsonException ( "Please provide either username and password or IAM apikey to authenticate the service." ) ;
103- }
79+ IamApiKey = _iamApikey
80+ } ;
81+
82+ credentials = new Credentials ( tokenOptions , _serviceUrl ) ;
83+
84+ // Wait for tokendata
85+ while ( ! credentials . HasIamTokenData ( ) )
86+ yield return null ;
10487
10588 _service = new LanguageTranslator ( _versionDate , credentials ) ;
10689
0 commit comments