A React sample for creating an application that acts on behalf of a user using the Watson Work Services.
The Watson Work Services platform provides spaces for people to exchange messages in conversations. This sample app shows how to create an application that acts on behalf of a user. It also demonstrates how to authenticate an application and obtain the OAuth token needed to make Watson Work API calls.
See Prepare your App to run for more details.
To try the sample app do the following:
In your Web browser, go to Watson Work Services - Apps, create a new app and add the url of the server you will be running this application from https://localhost:3000/callback (if running locally). Make sure the /callback is included in this url. Next write down its app id and app secret.
Install Node.js 6+.
In a terminal window, do the following:
# Get the code
git clone https://github.com/watsonwork/watsonwork-authorize-as-user.git
# Install dependencies
npm install
# run server
HTTPS=true npm start
Once you start the server you will be presented with a form that will step you through the process of authenticating you and the application and at the end will allow you to create a messasge using this application that will then post to a space of your choice.
An app wishing to request access to act on behalf of a user will be able to do so if the app is published, shared with the user or if the user accessing the app is the owner of the app. Otherwise, the app will not be able to authenticate as the user
- Give application access to your account so it can act on your behalf.
- Use the Code attribute that is return from server to create a token request that will authenticate your application.
- Select a space to post you message.
- Enter message
- Submit message to space.