Anonymous call to REST / web service?

Posted by Community Admin on 03-Aug-2018 22:42

Anonymous call to REST / web service?

All Replies

Posted by Community Admin on 11-Apr-2011 00:00

I am trying to write a function in pure Javascript that will consume images in an album and display them somewhere else. Is this possible, or do I have to authenticate somewhere?

I was under the impression that the REST / web services obey the permissions set in Sitefinity, but I get an error doing this:

http://mydomain.com/Sitefinity/Services/Content/ImageService.svc/parent/4361489b-b776-4501-9999-ae941c73e546/

The error I get is:

"Detail":"..::login|session|expired::..\/Sitefinity\/Login\/Ajax"

But the anonymous permission for the album/image view is granted. Can you please some light on REST security? Thanks.

Posted by Community Admin on 12-Apr-2011 00:00

Hello Basem,

You should grant view permissions to the annonymous users or to the user you use, otherwise you need to authenticate a user through Telerik.Sitefinity.Security.Web.Services.Users service and then make another call to get the data.

Best wishes,
Ivan Dimitrov
the Telerik team


Posted by Community Admin on 12-Apr-2011 00:00

I tried this, but no luck. I thought the "Everyone" role would handle this, but I went ahead and added "Anonymous" and "Authenticated" to "View images" and "View this album" (screenshot attached). Without being logged in, I tried calling this URL:

http://mydomain.com/Sitefinity/Services/Content/ImageService.svc/parent/4361489b-b776-4501-9999-ae941c73e546/

But I still get this error:

"Detail":"..::login|session|expired::..\/Sitefinity\/Login\/Ajax"

Is anonymous calls not the intended use for REST services? If so, I can change my approach to server side to stick within guidelines. Thanks.

Posted by Community Admin on 13-Apr-2011 00:00

Hello Basem,

It turned out that you cannot call the service if the user is not authenticated. We check for the current user and whether this is authenticated by using ServiceUtility.RequestAuthentication();.  So there should be a valid user in the context.

Regards,
Ivan Dimitrov
the Telerik team


Posted by Community Admin on 13-Apr-2011 00:00

Thanks for the confirmation. May I suggest that client-side code should not have to authenticate if it is within the same domain origin? Such as, why should client-side scripts have to authenticate for publicly accessible content if the call is coming from my-sitefinity-site.com/somepage. I could understand if some-random-site.com/test.html is trying to make the call.. but even in that case they should be able to authenticate using an app id or something for publicly accessible content. Just my 2 cents :) Thanks again.

Posted by Community Admin on 14-Apr-2011 00:00

Hello Basem,

Yes, this is something that we are going to implement in Q2/Q3.

Kind regards,
Ivan Dimitrov
the Telerik team


Posted by Community Admin on 20-Feb-2012 00:00

Hi Basem / Support,

Is there any documentation or example on how to authenticate a user by using the REST service?
I want to authenticate a user to make use of the webservices. I'm calling them from a javascript app and an iOS app.

Thanks,
Daniel

Posted by Community Admin on 21-Feb-2012 00:00

Hello,

There is a method of the Users service - AuthenticateUser that you can use

AuthenticateUser(Credentials credentials) - returns UserLoggingReason
Method = "POST",  ResponseFormat = WebMessageFormat.Json)]
Comment = "Sets authentication cookies to the current request if the provided credentials are valid.")]


Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Feb-2012 00:00

Hi Ivan,

When navigating to this service, I'm getting the following message:

"Detail":"..::login|session|expired::..\/Sitefinity\/Login\/Ajax"

So, how can we use the services, without the need to login?

Daniel

Posted by Community Admin on 21-Feb-2012 00:00

Hi,

Have you passed the credentials to it?

Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Feb-2012 00:00

No, I tried to access the /help file. But I'll try this first.

Thanks,
Daniel

Posted by Community Admin on 12-Apr-2012 00:00

@Daniel
Did you get this to work?
I am having the same issue

Posted by Community Admin on 13-Apr-2012 00:00

Hi,

Please see this post http://www.sitefinity.com/devnet/forums/sitefinity/developing-with-sitefinity/sf-5-0-consuming-wcf-rest-services-from-an-external-net-app.aspx 

Basically, the AuthenticateUser operation cannot be used anymore in SF 5.0 because it requires the user to be authenticated when performing the call ( how ironic).

You need to send Authentication Headers as described in the link above. Then, you'll get a cookie back and you can insert this cookie for the next calls.
Even though this link describes the code in .NET, the principle remains similar from javascript.

Posted by Community Admin on 29-Nov-2012 00:00

Hi Daniel,

I happened to read the post that you had about trying to access the authenticate webservice from javascript. were you able to make that call. If so do you happen to have the sample code for that? I am tring to do the same and am not successfull.
Any guidence appreciated.
Thanks

Posted by Community Admin on 29-Nov-2012 00:00

There was still issues with this so I ended up wrapping the Sitefinity requests with WebAPI:
blog.falafel.com/.../using-asp.net-web-api-for-sitefinity-rest-services

Posted by Community Admin on 29-Nov-2012 00:00

It would be cool if this was a priority to fix...like we have this cool tool in Icenium, but no way to get to our SF data through it.

Posted by Community Admin on 17-Feb-2015 00:00

Did anyone get a solution for this? Still struggling with getting Javascript to pull in some data anonymously on the client.

Posted by Community Admin on 17-Feb-2015 00:00

No, you have to roll your own...but on the plus side you can use servicestack to impliment and it's a billion times faster than the native wcf services...

 

(Servicestack is included in Sitefinity, all new services use it, they haven't migrated old ones yet)

Posted by Community Admin on 17-Feb-2015 00:00

Thanks Steve. I'll take a look at it. Shame it was never implemented though -1 for sitefinity :(

Posted by Community Admin on 18-Feb-2015 00:00

We ended up creating an SDK for Sitefinity that also includes web services out of the box: Babaganoush SDK

Posted by Community Admin on 17-Mar-2015 00:00

Thank for sharing.

This thread is closed