Retrieve Authentication-Token header from backendless 4.0 for file download in .NET

I currently working on a app in .NET that connects to backendless 4.0

The idea is that the user can upload a companylogo to backendless and that works. Only when trying to get the file with WebClient class (you don’t provided a function to get a file) I get a http 400 error.

I probably have to pass my usertoken (Authentication-Token). But how can I retrieve that in .NET? There isn’t a manual for .NET for the 4.0 version.

Regards,

Kris

Hi Kris,

You need to add the authentication token only if you have explicitly restricted the non-authenticated access for the files. However, if you do need to get the user token value, please use the following code:

string userToken = HeadersManager.GetInstance().Headers[ HeadersEnum.USER_TOKEN_KEY ];

where HeadersManager and HeadersEnum are in the BackendlessAPI.Engine namespace.

Regards,
Mark

Hi Mark,

Is it possible that HeadersManager isn’t a public class? The name BackendlessAPI.Engine doesn’t contain any classes. I’m using the last backendless.dll (2 days old).

Regards,

Kris

Hi Kris,

You are absolutely correct, they are internal classes. Sorry about that, let’s fix it real quick…

Mark

This is fixed now:

https://github.com/Backendless/.NET-SDK/tree/4.0/Backendless/Bin/NET_40

Use the following line of code:
string userToken = HeadersManager.GetInstance().Headers[ HeadersEnum.USER_TOKEN_KEY.Header ];

Mark,

Thanks for the fast responds and solutions. I allready implemented it in my code and it works!

Have a nice weekend!

Kris