steamhead 7 Posted August 21, 2020 Share Posted August 21, 2020 Hi folks, new to the Emby API. I've managed OK getting authentication via api_key working, but also want to look at how you do it via User. Looking at the Wiki, the first thing it says is "Add the following request header on every request: Authorization=Emby UserId="e8837bc1-ad67-520e-8cd2-f629e3155721", Client="Android", Device="Samsung Galaxy SIII", DeviceId="xxx", Version="1.0.0.0" Where userid is the ID of the current logged in user. Which leaves me baffled at the first hurdle, if I want to authenticate then a user won't be logged on, and as that userId looks nothing like any of my userIds I assume it's the internal ID, which presumably you have to look up from somewhere. I've looked at Swagger and most of the services to find out about users seem to need you to already be authenticated to do that, at which point my cart is simultaneously both before and after the horse So I'd appreciate a few examples of the calls you need to make, perhaps as if done via curl, as I understand what all the bits are for that (mostly) for the sequence of events needed to authenticate as a user, and then what you do with that on all other requests. I just need to see which bits go where. Thanks in advance Dean Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted August 21, 2020 Share Posted August 21, 2020 Not sure the wiki is a great source of info as usually it not very verbose so to use the "authenticatebyname" endpoint - in this case using powershell but should be easy to migrate to vbscript $embyClientName = "PS-Test" $embyDeviceName = "PowerShell" $embyDeviceId = "20.2.2" $embyApplicationVersion = " - 1234567" $embyServerUrl = "http://192.168.1.100:8096" $AuthUrl = $embyServerUrl + "/Users/AuthenticateByName?format=json" $Body = @{Username="$username";pw=$Pwd} | ConvertTo-Json $Header = @{"Authorization"="Emby Client=`"$embyClientName`", Device=`"$embyDeviceName`", DeviceId=`"$embyDeviceId`", Version=`"$embyApplicationVersion`""} $LoginResult = Invoke-WebRequest -Uri $AuthUrl -Method POST -Body $Body -ContentType "application/json" -Headers $Header $User = $Loginresult.content | convertfrom-json then $User.Accesstoken is what you use for api_key= 1 Link to comment Share on other sites More sharing options...
steamhead 7 Posted August 21, 2020 Author Share Posted August 21, 2020 I'm beginning to realise that about the Wiki Thanks for this, I'll try and get a go at this over the weekend and see what happens. You can't beat examples for communicating how to do something. Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted August 21, 2020 Share Posted August 21, 2020 yep - found a github post 3 yrs ago that had a way to do it that method has changed since then but the above works the wiki is almost useless now as nobody updates or maintains it - and authbyname is missing with any worthwhile examples Welcome to the club! Link to comment Share on other sites More sharing options...
steamhead 7 Posted August 23, 2020 Author Share Posted August 23, 2020 Got it working in PowerShell, thanks, now to translate to VBScript. This is my first request with a Body or Headers in VBScript, so got to figure out the format, fingers crossed shouldn't take too long. Link to comment Share on other sites More sharing options...
steamhead 7 Posted August 23, 2020 Author Share Posted August 23, 2020 So finally got the AuthenticateByName working in VBScript, once I realised the -ContentType argument in PowerShell becomes an extra header in VBScript - Thanks for the help. But then when I switched what was my straight emby/Items query to a emby/Users/xxxx/Items query (where xxxx is the actual name of the user I use, and I switched the app_key to use the value obtained from the AccessToken, and I get "Input string was not in a correct format", even though aside from the user directory and the AccessToken this is exactly the same format as before - what am I missing? http://nnn.nnn.nnn.nnn:8096/emby/Users/xxxx/Items?Recursive=true&path=%2Fmnt%2Fmedia%2Fsamba%2FAudio%2FAudio Drama%2FDoctor Who%2FVienna%2FVienna #03%2FVIEN-03_03 Impossibly Glamorous.mp3&api_key=4bcacd33749d41d287c7c810e37c8dcd Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted August 23, 2020 Share Posted August 23, 2020 xxxx is not the name of the user! its the user id Link to comment Share on other sites More sharing options...
steamhead 7 Posted August 23, 2020 Author Share Posted August 23, 2020 Ah, the dangers of using common synonyms in documentation and then not giving examples Thanks, working now. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now