Which Java implementation of OAuth for Telldus Live

Moderator: Telldus

Post Reply
peso70
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Which Java implementation of OAuth for Telldus Live

Post by peso70 »

Hello,
I am coding in java and would like to connect to Telldus Live to get my temp values.
As I understand from the PHP example I need to use OAuth, but for java which implementation is verified to work with Telldus Live?

Also, if someone has an example for java I would appreciate it!

Thanks in advance!
/Peter
micke.prag
Site Admin
Posts: 2243
Joined: Fri Mar 17, 2023 9:45 am
Location: Lund
Contact:

Re: Which Java implementation of OAuth for Telldus Live

Post by micke.prag »

There is some java libraries available here: http://oauth.net/code/
Micke Prag
Software
Telldus Technologies
peso70
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Re: Which Java implementation of OAuth for Telldus Live

Post by peso70 »

Just an update on how I successfully accessed the Telldus Live API to get the sensor data using Java and the Scribe implementation of OAuth.

Scribe can be downloaded from here: https://github.com/fernandezpablo85/scribe-java

Please observe a couple of things:
1. The code is not complete, but should be sufficient for most people to start.
2. Scribe needs a provider and I set it to "GoogleApi.class" which seams to work, but I do not know if it is correct.
2. I have gotten the apiKey (AAAaaaAAA in the code below), apiKeysecret (BBBbbbBBB), access token (XXXxxxXXX) and access token secret (YYYyyyYYY) from the Telldus website. You need to use your own keys/token instead.
3. I do not take any responsibility for if this code snippet is correct, safe or even allowed.

Code: Select all

import org.scribe.builder.*;
import org.scribe.builder.api.*;
import org.scribe.model.*;
import org.scribe.oauth.*;

// Create OAuth service.
OAuthService lobj_OAuthService = new ServiceBuilder()
                .provider(GoogleApi.class)                                
                .apiKey("AAAaaaAAA")                                
                .apiSecret("BBBbbbBBB")   
                .debug()
                .build();

// Create access token.
Token lobj_AccessToken = new Token ("XXXxxxXXX", "YYYyyyYYY");
        
// Create, sign and send request.
OAuthRequest lobj_Request = new OAuthRequest(Verb.GET, "http://api.telldus.com/xml/sensor/info");
lobj_Request.addQuerystringParameter("id", "12345");     // change 12345 to your sensor id.
lobj_OAuthService.signRequest(lobj_AccessToken, lobj_Request);
Response lobj_Response = lobj_Request.send();
        
// Print the result.
System.out.println("Response: " + lobj_Response.getBody());
christho
Posts: 1
Joined: Fri Mar 17, 2023 9:45 am

Re: Which Java implementation of OAuth for Telldus Live

Post by christho »

I am trying to connect with this method.
However, when I try to execute the code I get the following error:
"OAuth Verification Failed: Verification of signature failed"

I have registered for a private key?
Anyone who has some ideas?
Post Reply