Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I am looking for examples to call API to validate the user name and password and generate access token using OAuth 2.0 while user login to Thingworx
Steps I like to perform:
1) User enters user name / password
2) Thingworx call external API ( /token) to validate the entered user credentials
3) The external API will validate user/password against authentication system such as active directory.
4) The external API and send back access token for further calls to the external
Solved! Go to Solution.
Hello @hossamr77,
You might be interested in Single Sign-On Authenticators. Please refer to the following help center links for more information on Single SIgn-On Authentication and how to set up Ping Federate:
By using SSO, you are able to use your own Active Directory for authentication into ThingWorx, such as Azure AD, for example. Let me know if this is helpful.
Thanks,
Emmanuel
Hello @hossamr77,
Have you looked into the ContentLoaderFunctions? This collection of functions allows ThingWorx to communicate with external APIs through REST calls. For more information, refer to ContentLoaderFunctions in ThingWorx.
When creating a service, navigate to Snippets > ContentLoaderFunctions and choose the desired request type. The available request types include POST, GET, DELETE, and PUT. You can also specify the username and password fields to authenticate to your external API. The result JSON variable can be used to add the token into a data table or another entity type, according to your use case.
I hope you find this information useful in creating services that communicate with external APIs through REST.
Regards,
Emmanuel
Hello emscur , i already able to call external API but i need to call API to authenticate the user on behalf of Thingworx and get access token.
Hello @hossamr77,
From what I understand, you are looking to authenticate with your external API via a mashup created in ThingWorx, right? The user will enter their username and password for external API while logged in to ThingWorx and authenticate.
If you have authentication in the backend server of your external API that handles tokens, then when you call the login API endpoint with username and password. it should return with the access token for the logged in user in the result variable. Since this is a JSON, you can access the token using something like result.token.
Let me know if this is what your are looking for. If not, please clarify your use case in a little more detail so we can better assist you.
Thanks,
Emmanuel
Yes that i need to do but i couldn't bypass thingworx login flow and switch to my authorization service external API.
Hello @hossamr77,
You might be interested in Single Sign-On Authenticators. Please refer to the following help center links for more information on Single SIgn-On Authentication and how to set up Ping Federate:
By using SSO, you are able to use your own Active Directory for authentication into ThingWorx, such as Azure AD, for example. Let me know if this is helpful.
Thanks,
Emmanuel
Hi @hossamr77.
If you feel that your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Thank you for your participation in our community!
Regards.
--Sharon