Hi,
I've changed to the new version of the JS SDK, so I've included in script path:
""
Next inside script.js I've added platformClient part:
const platformClient = require('platformClient');
Using ApiClient instance I log-in
client = platformClient.ApiClient.instance;
client.loginImplicitGrant(clientId, redirectUrl)
Then I check if client contain accessToken - if yes, I call getMe function:
var usersApi = new platformClient.UsersApi();
usersApi.getUsersMe()
What is strange - I receive
"{"status":401,"code":"bad.credentials","message":"Invalid login credentials."}"
client object contain all tokens etc ... should I pass it somehow to the UserApi() ?
Thanks
Daniel
Hi,
Have you remembered to specify the correct Environment ? (e.g mypurecloud.ie instead of mypurecloud.com )
You do this before the login request by referencing client.setEnvironment('mypurecloud.ie ') . This means that all subsequent API calls will use that Environment by default.
For example: if you use https://apps.mypurecloud.ie/ as your login to PureCloud, then you'd set your environment to 'mypurecloud.ie '.
There is no need to pass the Client to the UsersApi , each module has an internal reference to the Client.
1 Like
Hi,
Good finding!
I've set Environment before login, but after that I'm redirerted to the same index.html page, and before call getUsersMe() function I didn't set it second time.
I fixed that - it's working now !
Thanks a lot !
Daniel
1 Like
system
Closed
September 17, 2017, 11:07am
4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.