Skip to content

Commit e4fc2e5

Browse files
committed
update readme with token instructions
1 parent c8227be commit e4fc2e5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Use this SDK to build Watson-powered applications in Unity.
88
* [Getting the Watson SDK and adding it to Unity](#getting-the-watson-sdk-and-adding-it-to-unity)
99
* [Installing the SDK source into your Unity project](#installing-the-sdk-source-into-your-unity-project)
1010
* [Configuring your service credentials](#configuring-your-service-credentials)
11+
* [Watson Services](#watson-services)
12+
* [Authentication Tokens](#authentication-tokens)
1113
* [Documentation](#documentation)
1214
* [Questions](#questions)
1315
* [Open Source @ IBM](#open-source--ibm)
@@ -67,6 +69,45 @@ To create instances of Watson services and their credentials, follow the steps b
6769
* [Tradeoff Analytics](/Scripts/Services/TradeoffAnalytics/v1)
6870
* [Visual Recognition](/Scripts/Services/VisualRecognition/v3)
6971

72+
## Authentication Tokens
73+
### You use tokens to write applications that make authenticated requests to IBM Watson™ services without embedding service credentials in every call.
74+
75+
### You can write an authentication proxy in IBM® Bluemix® that obtains and returns a token to your client application, which can then use the token to call the service directly. This proxy eliminates the need to channel all service requests through an intermediate server-side application, which is otherwise necessary to avoid exposing your service credentials from your client application.
76+
77+
```
78+
using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
79+
using IBM.Watson.DeveloperCloud.Utilities;
80+
81+
void Start()
82+
{
83+
Credentials credentials = new Credentials(<service-url>)
84+
{
85+
AuthenticationToken = <authentication-token>
86+
};
87+
Conversation _conversation = new Conversation(credentials);
88+
}
89+
```
90+
91+
### There is a helper class included to obtain tokens from within your Unity application.
92+
93+
```
94+
using IBM.Watson.DeveloperCloud.Utilities;
95+
96+
AuthenticationToken _authenticationToken;
97+
98+
void Start()
99+
{
100+
if (!Utility.GetToken(OnGetToken, <service-url>, <service-username>, <service-password>))
101+
Log.Debug("ExampleGetToken", "Failed to get token.");
102+
}
103+
104+
private void OnGetToken(AuthenticationToken authenticationToken, string customData)
105+
{
106+
_authenticationToken = authenticationToken;
107+
Log.Debug("ExampleGetToken", "created: {0} | time to expiration: {1} minutes | token: {2}", _authenticationToken.Created, _authenticationToken.TimeUntilExpiration, _authenticationToken.Token);
108+
}
109+
```
110+
70111
## Documentation
71112
To read the documentation you need to have a **chm reader** installed. Open the documentation by selecting API Reference the Watson menu (**Watson -> API Reference**).
72113

0 commit comments

Comments
 (0)