davglass/doorbot

The new authentication with the default userAgent string is not working

lucwuyts opened this issue · 9 comments

I had to change the userAgent to something else, and this works (for now)

Question:
The token is not reused when I add the previous token to the call.
Is this correct?

Interesting, I just tested it and it works as expected with the current userAgent set..

What do you mean when you add the previous token? I'm not sure what you are doing. Can you provide an example please?

Yes, you're right. I tried again today, and it does work with the default userAgent. Must have been a murphy.

The token: if i use the previous token in the next call, it is not used, and a new token is returned.
I thought this tokens could be reused, so it would not be necessary to login again?

You shouldn't have to do anything but just make the calls. I handle the token under the hood and use it on all api calls. Can you show me some example code that you are using?

Nothing special

const ring = RingAPI({
email: 'xxxxxx',
password: 'yyyyy',
token: 'jLqNHtoRWGjB6ADy-TWm' // i was trying with the token from the previous call.
});

ring.devices((e,devices) => {

console.log(e,"Token: "+ring.token)
//console.log(devices);

var doorbots = devices["doorbots"];
var batt = doorbots[0]["battery_life"]

console.log( batt );
//client.publish('ring/battery' , batt , {qos: 2, retain: true } )		
//client.end()	

})

You don't need to pass the token around, the module handles this for you. Are you trying to do it to save logging in each time the script is executed instead of persisting the script? Right now this.token is set to null in the constructor so it's not used and it's just re-authenticated. You can test this by changing this line:
https://github.com/davglass/doorbot/blob/master/doorbot.js#L57

To this:

this.token = options.token || null;

If that does what you are expecting let me know and I can patch it and write a test for it..

I changed this line, and i can confirm the token from my test 10 hours ago is still working.

There probably is an expiration time for the token

Published in doorbot@5.0.1

Sfinx commented

Their API started making additional checks for the user_agent field - you will have good empty 200 response always with "@doorbot", i.e. no events. Something like "android:com.ringapp:2.0.67(423)" still works.

Thanks @Sfinx, I've made that change an pushed up doorbot@5.0.2