+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Anonymous call to REST / web service?

Anonymous call to REST / web service?

21 posts, 1 answered
  1. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    11 Apr 2011
    Link to this post
    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.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    12 Apr 2011
    Link to this post
    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

  3. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    12 Apr 2011
    Link to this post
    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.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    13 Apr 2011
    Link to this post
    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

    Answered
  5. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    13 Apr 2011
    Link to this post
    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 http://my-sitefinity-site.com/somepage. I could understand if http://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.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    14 Apr 2011
    Link to this post
    Hello Basem,

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

    Kind regards,
    Ivan Dimitrov
    the Telerik team

  7. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    20 Feb 2012
    Link to this post
    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
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    21 Feb 2012
    Link to this post
    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
  9. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    21 Feb 2012
    Link to this post
    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
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    21 Feb 2012
    Link to this post
    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
  11. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    21 Feb 2012
    Link to this post
    No, I tried to access the /help file. But I'll try this first.

    Thanks,
    Daniel
  12. Ryan
    Ryan avatar
    3 posts
    Registered:
    23 Sep 2011
    12 Apr 2012
    Link to this post
    @Daniel
    Did you get this to work?
    I am having the same issue
  13. Yann
    Yann avatar
    19 posts
    Registered:
    24 Jun 2010
    13 Apr 2012
    Link to this post
    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.

  14. Sajitha
    Sajitha avatar
    3 posts
    Registered:
    19 Nov 2012
    29 Nov 2012 in reply to Daniel Plomp
    Link to this post
    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
  15. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    29 Nov 2012
    Link to this post
    There was still issues with this so I ended up wrapping the Sitefinity requests with WebAPI:
    http://blog.falafel.com/Blogs/BasemEmara/basem-emara/2012/06/20/using-asp.net-web-api-for-sitefinity-rest-services
  16. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    29 Nov 2012
    Link to this post
    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.
  17. Kevin
    Kevin avatar
    2 posts
    Registered:
    27 Jan 2015
    17 Feb 2015
    Link to this post
    Did anyone get a solution for this? Still struggling with getting Javascript to pull in some data anonymously on the client.
  18. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    17 Feb 2015 in reply to Kevin
    Link to this post

    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)

  19. Kevin
    Kevin avatar
    2 posts
    Registered:
    27 Jan 2015
    17 Feb 2015 in reply to Steve
    Link to this post
    Thanks Steve. I'll take a look at it. Shame it was never implemented though -1 for sitefinity :(
  20. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    18 Feb 2015
    Link to this post
    We ended up creating an SDK for Sitefinity that also includes web services out of the box: Babaganoush SDK
  21. noomclub
    noomclub avatar
    1 posts
    Registered:
    17 Mar 2015
    17 Mar 2015
    Link to this post

    Thank for sharing.

21 posts, 1 answered