Skip to content

Commit 901e5d4

Browse files
authored
Merge branch 'master' into master
2 parents 29a1348 + 1b264e1 commit 901e5d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1557
-118
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.13.1
2+
current_version = 2.15.0
33
commit = True
44
message = [skip ci] docs: Update version numbers from {current_version} -> {new_version}
55

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,5 @@ Docs/publishing-release.md.meta
7878
/Scripts/Editor/Help/
7979
/Scripts/Editor/Help.meta
8080
*/MRefBuilder.config.meta
81+
package-lock.json
82+
package-lock.json.meta

Assistant.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Assistant/v2.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Core.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Core/Editor.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Core/Editor/Help.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Core/Editor/Help/Working.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "IBM Watson SDK for Unity"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 2.13.1
41+
PROJECT_NUMBER = 2.15.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,51 @@ void Start()
179179
}
180180
```
181181

182+
### Supplying credentials
183+
184+
There are two ways to supply the credentials you found above to the SDK for authentication.
185+
186+
#### Credential file (easier!)
187+
188+
With a credential file, you just need to put the file in the right place and the SDK will do the work of parsing it and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance.
189+
190+
The file downloaded will be called `ibm-credentials.env`. This is the name the SDK will search for and **must** be preserved unless you want to configure the file path (more on that later). The SDK will look for your `ibm-credentials.env` file in the following places (in order):
191+
192+
- Your system's home directory
193+
- The top-level directory of the project you're using the SDK in
194+
195+
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
196+
197+
```cs
198+
public IEnumerator ExampleAutoService()
199+
{
200+
Assistant assistantService = new Assistant();
201+
assistantService.VersionDate = _assistantVersionDate;
202+
203+
// Wait for authorization token
204+
while (!assistantService.Credentials.HasIamTokenData())
205+
yield return null;
206+
207+
var listWorkspacesResult = assistantService.ListWorkspaces();
208+
}
209+
```
210+
211+
And that's it!
212+
213+
If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services.
214+
215+
If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that:
216+
217+
```bash
218+
export IBM_CREDENTIALS_FILE="<path>"
219+
```
220+
221+
where `<path>` is something like `/home/user/Downloads/<file_name>.env`.
222+
223+
#### Manually
224+
225+
If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of credentials your service instance gives you.
226+
182227
## Callbacks
183228
Success and failure callbacks are required. You can specify the return type in the callback.
184229
```cs

Scripts/Connection/RESTConnector.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.Text;
2727
using UnityEngine;
2828
using UnityEngine.Networking;
29+
using System.Text.RegularExpressions;
2930

3031
#if !NETFX_CORE
3132
using System.Net;
@@ -375,7 +376,24 @@ private void AddHeaders(Dictionary<string, string> headers)
375376
}
376377
}
377378

378-
headers.Add("User-Agent", Constants.String.Version);
379+
string osInfo = SystemInfo.operatingSystem;
380+
Regex pattern = new Regex("\\d+(\\.\\d+)+");
381+
Match m = pattern.Match(osInfo);
382+
string osVersion = m.Value;
383+
string os = osInfo.Replace(osVersion, "").Replace(" ", "");
384+
if(os.Contains("()"))
385+
{
386+
os = os.Replace("()", "-");
387+
}
388+
389+
headers.Add("User-Agent",
390+
string.Format(
391+
"{0} {1} {2} {3}",
392+
Constants.String.Version,
393+
os,
394+
osVersion,
395+
Application.unityVersion
396+
));
379397
}
380398

381399
private IEnumerator ProcessRequestQueue()

0 commit comments

Comments
 (0)