cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Add ThingWorx Login Functionality to Unity App

EJ_10785345
4-Participant

Add ThingWorx Login Functionality to Unity App

I’m developing an app in Unity and need our users to be able to log in through it as they would on the ThingWorx login page (https://support.ptc.com/help/thingworx/platform/r9.5/en/#page/ThingWorx/Help/Composer/Security/Organizations/CreatingLoginPageFormsforOrganizations.html#).

I’m having the same problem at the OP here: https://community.ptc.com/t5/ThingWorx-Developers/Login-Implementation-with-username-password-via-Things-Service/m-p/662474

The value I get returned from the server is the HTML for the login page. I have tried setting the Accept header to "application/json", “text/plain”, and “text/csv” but to no avail. Unlike as described in the response by PEHOWE in the above link, I get the same HTML when testing in Postman.


My code is essentially the same (but using UnityWebRequest.Post()) as the OP here: https://community.ptc.com/t5/ThingWorx-Developers/C-based-login-fails-with-401/m-p/505077


Thanks in advance for any help.

3 REPLIES 3

Hi @EJ_10785345 

 

Have you checked Thingworx Dot Net SDK 

Welcome to the ThingWorx Edge .NET SDK Help Center (ptc.com)

.NET SDK: SecurityClaims Class (ptc.com)

 

I'm not a unity guy, but I think you can use Thingworx DLL to authenticate with Thingworx from Unity App.

 

/VR

 

@EJ_10785345 ,
I have used Unity  a little. I am a little unclear as to what information you have and what you want to accomplish. You should be able to make a REST API call to ThingWorx passing userid and password. If the information is sent successfully and is valid you should get back a status of 200 and a session ID. 
What URL are you using?
Do you have the ThingWorx User name and Password?

What type of response are you getting?

 

Pehowe

Velkumar and PHOWE, thank you both for your replies.

 

As it turns out, the issue was that Visual Studio had "helped" me with some syntax and I didn't realize it. When I had copy/pasted both "thingworx-form-userid" and "thingworx-form-password" from the HTML form, VS changed them to "thingworx-wwwForm-userid" and "thingworx-wwwForm-password". I propagated the issue when I copy/pasted from VS into Postman.

 

When I realized what had happened and corrected it, everything worked as expected.

Top Tags