Table of contents

Develop applications for Watson Studio Local

Watson Studio Local provides REST APIs to perform a variety of tasks.

The following tasks require user authentication to run:

User authentication

Watson Studio Local requires a bearer token to authenticate the user calling the REST APIs. The token lasts for 13 hours. The following example shows how to retrieve a bearer token from the user management service:

curl -k -X GET
<WSL_URL>/v1/preauth/validateAuth -u joe:joespasswd

where <WSL_URL> represents the Watson Studio Local URL, joe represents a user that exists in Watson Studio Local, and joespasswd represents the password.

The call returns a JSON from which the bearer token can be extracted from the accessToken field:

{"username":"joe",
 "role":"User",
 "uid":"1003",
 "accessToken":"eyJhbGc...1AjT_w",
 "_messageCode_":"success",
 "message":"success"
}

The value of the accessToken field can be stored into a variable that can be used for authenticate subsequent operations. Example:

bearerToken=`curl -k -X GET
<WSL_URL>/v1/preauth/validateAuth -u joe:joespasswd | jq
-r '.accessToken'`

The user ID value in the uid field indicates the home directory of the user, for example, /user-home/1003/. The uid can be used to refer to local files that your Spark application might want to process.