automatic login to appservices when using REST

I make a webclient written in Javascript, HTML5, CSS3 that does calls to the REST appservices. The first time I do a call to the appservices a login page pops up. Therefore I want to program the login in the HTML page.

Is there a way in javascript to automaticly do a login to the application and use REST appservices without having to login manually ?

I use an integrated .net membership in the database.
I do not want to use anonymous REST calls for security reasons.
2 people have
this question
+1
Reply
  • Peter,

    You can add the username and password using basic Authorization header. You can also post to "/_invoke/Login" with JSON { username: "username", password: "password" } and use the returned token for a Bearer authorization header.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • I’m frustrated
    Hi Dennis, Thank you for the respons. I tried the post to "/_invoke/Login" but i get an error. I tried with a login screen where you can enter username and password, just for testing purposes, but still the same error.

    Is there an example how to use the /_invoke...?

    this is my code : The alert I get is "Failed: [object Object] "

    <!DOCTYPE html SYSTEM>

    autologin 1

    <!-- this tag is needed to enable jQuery IntelliSense only -->

    <!-- the implementation of the product catalog -->

    <!-- the user interface of the control -->






  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Peter,

    You may need to add the "createPersistentCookie" property to the payload. See example below:

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • I’m sad
    I have a complete HTML program with authentication connected with REST to a COT program.
    I upgraded COT to 8.9.4, since then the login request does not work anymore.

    Before starting to dig in the code, perhaps you can give me a clue what a possible solution could be.
    I had a similar problem 2 years ago.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Not sure if this is same scenario or not, but I experienced a problem where the login request wasn't working anymore. I still don't know what happened, but I fixed it by updating the C# client code. Instead of using NetworkCredentials I manually added the Basic Authorization header.


    HttpWebRequest request3 = (HttpWebRequest)WebRequest.Create("https://my.website.com/appservices/MyController/grid1?_pageSize=1000000");
    request3.Method = "GET";
    request3.Accept = "application/xml";
    request3.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(user + ":" + pwd)));
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated