Jump to content

[API] Login with external form


Recommended Posts




I'm trying to create a webform where you can create an account and login into Emby without having to login in 'https://domain.com/web/index.html#!/startup/login.html?serverId=123'. 

I've noticed that when you authenticate a user, this user stays authenticated throughout the entire browser. So I thought if I did a '/Users/AuthenticateByName' call in the form, this would would authenticate the user like it would when you normally login but it doesn't.


So basically I call '/Users/AuthenticateByName' with my desired username and password I want to login, this does the job but when I go to the same url as provided in the api call, it still asks me to login. Both in the same browser.


My code to authenticate the user: 

function userAuthenticate($username,$password)
        $dataArray = array("Username"=>$username, "Pw"=>$password);
        $dataString = http_build_query($dataArray);
        $url= 'https://domain.com/emby/Users/AuthenticateByName?api_key=123456789&';

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $response = curl_exec($ch);
        $responseDecoded = json_decode($response,true);
        echo $responseDecoded["AccessToken"];

The code above does always succeed but doesn't do what I want (that is authenticating the user in https://domain.com/web).


Now I'm wondering if it is possible to accomplish what I just described.


Thanks in advance!

(I'm sorry if I didn't describe my problem very well, I didn't really know how to  :unsure: )



Link to comment
Share on other sites




I found some kind of solution that I'd like to share, I'm just wondering if it's frowned upon to add/adjust code to fit your needs? If so, I'll just drop it, if not I'm happy to share my findings.

The 'overwritten at every update' issue is no longer valid since I created a script that will make the changes every update (unless of course some major things change).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...