Jump to content

How to communicate with MBS


Recommended Posts

Posted (edited)

Hello Folks.

 

I have a problem with the authentification by user process. This is what I send to the server:

Content-Type: application/x-www-form-urlencoded
Authorization=MediaBrowser UserId="FFFFFF-ad67-ffff-ffff-f629e3155721",Client="Android", Device="Samsung Galaxy SIII", DeviceId="12345", Version="1.0.0.0"
Username=Tranquil Password=0a01153e3856d53a7b665be6b0b42effffffffff PasswordMd5=ab7d4316ffc25f1dec9211ffffffffff
 
And I always get this response:
 

{
  "ResponseStatus": {
      "Message"   : "Invalid username or password entered.",
      "Errors"    : [],
      "ErrorCode" : "SecurityException",
      "StackTrace": "[AuthenticateUserByName: 12.02.2015 14:33:52]:\n[REQUEST: {Username:Tranquil Password=0a01153e3856d53a7b665be6b0b42effffffffff PasswordMd5=ab7d4316ffc25f1dec9211ffffffffff}]\nMediaBrowser.Controller.Net.SecurityException: Invalid username or password entered.\r\n   bei MediaBrowser.Server.Implementations.Library.UserManager.<AuthenticateUser>d__16.MoveNext()\r\n--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---\r\n   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   bei System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n   bei MediaBrowser.Server.Implementations.Session.SessionManager.<AuthenticateNewSession>d__db.MoveNext()\r\n--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---\r\n   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   bei MediaBrowser.Api.UserService.<Post>d__17.MoveNext()"
    }
}

 
What I'm doing wrong? (SHA1 and MD5 are modified in this example but are correct in my source)
 
Edit: Just to notice: I'm completely now to this so I'm just playing around a bit. :-)
Edited by Tranquil
Posted
Posted

Hi Chef.

 

Thanks for taking a look. You are right, the UserID does not exist at this early stage so I should leave it blank. Unfortunately I cant login a user anyway. It is still saying "wrong username or password".

I'm also not able to login a user using the swagger-ui. If I fill the required fields I get a 

{ "ResponseStatus": { "ErrorCode": "RequestBindingException", "Message": "Unable to bind request", "StackTrace": " bei ServiceStack.Host.RestHandler.CreateRequest(IRequest httpReq, IRestPath restPath)\r\n bei ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)" } }

My intention is, in a first step. port the API to my favorite language PureBasic and get deeper into Swagger-API support and maybe code some stuff for MBS.

Posted

You haven't encoded your parameters properly.  All of them are ending up in username.

Username:Tranquil Password=0a01153e3856d53a7b665be6b0b42effffffffff PasswordMd5=ab7d4316ffc25f1dec9211ffffffffff
  • Like 1
Posted (edited)

I thought this, what is the correct separator for this? 

 

EDIT: Got it! thanks for spotting on this!

Edited by Tranquil
Posted (edited)

Nice

Edited by chef
  • Like 1
Posted

I think I now have everything I need to communicate with MBS correctly.

First I thought I have to pass a Json structured body to the server.The parameters just have to be separated by a logical & symbol. I'm not a web developer so I have some lack of information here but google is a good friend. :-)

 

If I have enough time at this weekend I will maybe create a module for PureBasic so that everyone can gain benefit of it in the PB community.

Posted

It would be better to past post parameters as a json-encoded post body instead of url parameters. 

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