Jump to content

Emby Connect Invite via API


Recommended Posts

msmcpeake
Posted

Hello, I am trying to automate the creation of accounts and adding their Emby ID from a form.  What is the proper way of sending an invite from my server via a link/API call?  I cannot find great documentation about this.  I would like to be walked through it if possible.  Thanks!

rechigo
Posted (edited)

Make a post request to this URL: http://<address>:<port>/emby/Users/<userid>/Connect/Link

 

with a content type of application/json

 

In the json body, you want to add a ConnectUsername property, which will contain the username/email of the connect account you wish to link

 

(this also needs the X-Emby-Token header containing an emby api key otherwise the request will fail)

 

Let me know if you need anymore help, this is just a brief explanation

Edited by rechigo
rechigo
Posted

This is how it would look if you wanted to call it using cURL: 

curl -X POST -d "{\"ConnectUsername\":\"<yourconnectusername>\"}" -H "X-Emby-Token:<yourapikey>" -H "Content-Type:application/json"  http://<address>:<port>/emby/Users/<userid>/Connect/Link
  • Like 1
msmcpeake
Posted

 

This is how it would look if you wanted to call it using cURL: 

curl -X POST -d "{\"ConnectUsername\":\"<yourconnectusername>\"}" -H "X-Emby-Token:<yourapikey>" -H "Content-Type:application/json"  http://<address>:<port>/emby/Users/<userid>/Connect/Link

 

 

This is the error I receive:

curl -X POST -d "{\"ConnectUsername\":\"msmcpeake\"}" -H "X-Emby-Token:<redacted>" -H "Content-Type:application/json"  http://<redacted>:8096/emby/Users/msmcpeake/Connect/Link

Input string was not in a correct format.


rechigo
Posted (edited)

 

This is the error I receive:

curl -X POST -d "{\"ConnectUsername\":\"msmcpeake\"}" -H "X-Emby-Token:<redacted>" -H "Content-Type:application/json"  http://<redacted>:8096/emby/Users/msmcpeake/Connect/Link

Input string was not in a correct format.


 

you can't use your username, you have to use your user id

Edited by rechigo
msmcpeake
Posted (edited)

Just for anyone struggling in the future, this is my PHP CURL configuration.  Just figured this all out thanks to rechigo

 

 

I passed Username from a form on a web page (the variable $name), then created a user on Emby from that variable. I then got the output from curl and got the user Id ($userid), and put the two together to link Emby Connect to the user!

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, '<server ip>:8096/emby/Users/New?api_key=<api key>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"Name\":\"{$name}\"}");

$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);



if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
					
				
				
$json = json_decode($result, true);				
$userid = $json['Id'];				
				
				
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "<server ip>:8096/emby/Users/{$userid}/Connect/Link?api_key=<api key>");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"ConnectUsername\":\"{$name}\"}");

$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result2 = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Edited by msmcpeake
rechigo
Posted

Glad you got it working\!

  • 3 months later...
Posted

Hi, do you know how to work with the PIN ?

I don't understand how it works neither manually or by API

Posted
On 7/10/2020 at 3:38 AM, maxt.v said:

Hi, do you know how to work with the PIN ?

I don't understand how it works neither manually or by API

hi @maxt.v what exactly are you trying to do?

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...