AccessToken for LiveAPi calls

Moderator: Telldus

Post Reply
Lazzerman
Posts: 3
Joined: Thu Jan 18, 2018 11:08 am

AccessToken for LiveAPi calls

Post by Lazzerman » Sat Jun 15, 2019 8:41 pm

Hello,

First: I don't speak PHP - script languages are…. :-)

Question:

I wan't to call LiveAPI from my desktop app(private) - I really don't want to login via the Telldus API Login page - I just want some nice API calls to get me the AccessToken. is that possible?

I have the keys from Telldus:

Public key:

Private key:

Token:

Token secret:

But in the PHP samples(?) - these variables doesn't seem to be used? At least not with the same names?

Could some one please enlighten me - preferably using C/c#/c++ or at least readable and "complete" code.

TIA!

// Lars

Lazzerman
Posts: 3
Joined: Thu Jan 18, 2018 11:08 am

Re: AccessToken for LiveAPi calls

Post by Lazzerman » Sat Jun 15, 2019 10:29 pm

Found some code that I could make to work:

using RestSharp;
using Newtonsoft.Json;
using RestSharp.Authenticators;

private const string PublicKey = "YourCodeFromTelldus";
private const string PrivateKey = "YourCodeFromTelldus";
private const string Token = "YourCodeFromTelldus";
private const string TokenSecret = "YourCodeFromTelldus";

private const string BaseUrl = "http://api.telldus.com/";

private void Btn_livelogin_Click(object sender, EventArgs e)
{
var client = new RestClient(BaseUrl);
client.Authenticator = OAuth1Authenticator.ForProtectedResource(PublicKey, PrivateKey, Token, TokenSecret);
var request = new RestRequest("json/devices/list", Method.GET);
var response = client.Execute(request);

dynamic res = Newtonsoft.Json.JsonConvert.DeserializeObject(response.Content);
}

// Cheers

Post Reply