I’m trying to consume smartapp with oauth from c# desktop application.
Authenticating via curl and consuming via browser worked fine.
I’ve tried several ways:
via Microsoft.oswin - But I couldn’t get to authenticate.
via regular process start: authentication went well, but I failed to retrieve the json’s via httpRequests.
(2) is also ugly because of the authentication method.
This might not be the best way to implement it, but it should work.
If you enable OAuth and generate the Access Token through the SmartApp that SmartApp will have a public url you can access from anywhere without being authenticated.
You can use the mappings in the SmartApp to specify methods to execute based on the url. You can pass information into that method using parameters in the url of a get request or by extracting the json data from a post request.
From that method you can use render to return html and I believe you can also use it to return json, but I haven’t tested that.
If you can’t return json from that method you could use that method to post the information to a public url or use sendhubaction to post it back to the computer on your local network.
The “mappings” section and methods that start with “api_” in the 2 SmartApps below provide examples of everything mentioned above.
Simple Device Viewer accepts information passed through get requests and uses render to return html.
Simple Event Logger parses json from a post request and also posts json to an external url.
Thanks
Isn’t creating a token from inside the smartapp can effect remote security?
What is the public address created for ‘createApiToken’ method in use in that code?
Will I be able to access from httpWebRequest (C# call)?
I intend to write a wpf application controlling my home and alarm, that will execute in windows tablet in several locations in my house. Security for that kind of smartapp is critical.
The public url contains the application id and the unique token you generate from within the SmartApp.
If you install multiple instances of the SmartApp they’ll all have different urls and you can change the url at any time by regenerating the access token.
I think the security risk is low as long as you don’t give out the url or access it from a public computer or network.
The url returns a response just like any other website so you should be able to use httpWebRequest.