TiVo Community Forum banner
1 - 9 of 9 Posts

·
Registered
Joined
·
93 Posts
If you are going to rewrite it I would also switch to the websocket so you don't need to worry about the client certificate expiring. I'm not a python developer but I think if you wanted to keep the python code beyind getting the token (you could have people pull the cookie from their browser).
Code:
    self.Write(RpcRequest('bodyAuthenticate',
        credential={
            'type': 'mmaCredential',
            'username': username,
            'password': password,
            }
        ))
would become
Code:
    self.Write(RpcRequest('bodyAuthenticate',
        credential={
            domainToken={
                'domain': 'tivo'
                'token': 'the cookie token here'
                'type': 'domainToken'
            }
        ))
I've started working on building a javascript (node) client to pull the token and you start with TiVo Online you'll get 302 redirected to another page with a form you'll need to pull the two hidden fields and the post url.

That post will 302 redirect you to the sign in page. there's another post that happens to get what all is enabled you can ignore that

the next post to
https://tivoidp.tivo.com/s/sfsites/aura?r=1&other.Tivo_idp_LightningLoginForm.login=1 does the real login. Based on my experience with salsforce aura.context does change from time to time so you'll need to extract it from the page. aura.pageURI is the same as the page you were redirected to without the domain/protocol. This will give you a frontdoor url
that should redirect you to another page that will have the saml response extract that do the saml post and you'll have your cookie.
 

·
Registered
Joined
·
93 Posts
You would need to use the websocket to no longer need the client certificate. I find the websocket a lot easier then the raw tls connection as you'll get a whole response in one websocket message.

The domainToken cookie is a session cookie for a given user that is good for I think a week.

If I finish my node client it would be super easy to make a rest http server that you bundel and run instead of making individual calls.
 

·
Registered
Joined
·
93 Posts
I was thinking you would have MG3 call the node (javascript not java) server directly as a simple http interface to make mind calls. I could also make a node script that takes parameters like the python script does. I still think the websocket client would be fairly easy to write in c# the harder part is all the parsing you need to do for getting the cookie.

There is at least one request where you need to pass it a real browser user agent or you'll get a error message but a 200 http response.
tivo-scripts/getDomainToken.js at master · lart2150/tivo-scripts
 

·
Registered
Joined
·
93 Posts
For some of the calls to tivoidp.tivo.com you need to send a browser user agent header like chrome or firefox, node and user agents curl don't work. You could look at my code and try and convert it to c# I use some dom parsing and regular expressions. The one wonky thing I do is on line 48 where I limit the number of redirects because the cookie library has a bug.

When you install node there's an option to also install build tools via chocolatey. The build tools are not needed for any of the libraries I use. There is a npm package that can convert a node script into a self contained exe but it's about 25MB.
 

·
Registered
Joined
·
93 Posts
@dlfl hopefully this helps making the domain token code native. There is not really any error handling but a invalid password should throw an exception of some sort.

Consider the code MIT licensed. I do use one external library(Newtonsoft.Json).

Below is a compiled version
 

·
Registered
Joined
·
93 Posts
@lart2150 I'm not sure what conditions the MIT license imposes on this project. The program and my support are free to everyone. I was on the verge of trying to port your Java code to C#. I'm sure you saved me hours and hours of work!
MIT is very flexible and can be used for almost any project (closed source or most open source projects). KMTTG on the other hand is gpl v2 would require metagenerator to have a gpl v2 compatible license.
 

·
Registered
Joined
·
93 Posts
It smells like some kind of proxy buffering or similar that doesn't clear the first error in web request land. Any ideas?
that does sound like a cache issue. I wonder if something like this would help.
Code:
    HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
    HttpWebRequest.DefaultCachePolicy = policy;
 
1 - 9 of 9 Posts
Top