1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
    kmithemanth is on a distinguished road

      0  

    Default Unanswered: Rest Services Authentication

    Unanswered: Rest Services Authentication


    I have a rest call which works fine when i log in to the parent site ( the site which provides the rest call) from another browser tab. But when i use the call directly, (without logging in to the site from another tab) i'm getting error 401 Unauthorised. This is expected, but how do i authenticate my rest call?

    On searching the internet, i've seen a bunch of codes using this:
    proxy:{
    type: 'rest',
    url: 'somesite.com/restservice1',
    method: 'GET',
    username: 'user1',
    password: 'pass'
    }

    and also this:
    proxy:{
    type: 'rest',
    url: 'somesite.com/restservice1',
    method: 'GET',
    extraParams:{
    username: 'user1',
    password: 'pass'

    }
    }

    None of them work. How do i get it working? As many sites (almost all of them) use authentication with their rest services, there's got to be a way.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    extraParams will send the username/password as parameters. Is that what your setup is needing?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
    kmithemanth is on a distinguished road

      0  

    Default


    but it just appends the username and password to the url. i wanted something that actually authenticates before calling the rest service. is that possible?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The rest proxy isn't going to do that. You would need to send an initial request or on the server if not logged in and the username/password is in the request attempt an auto login.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
    kmithemanth is on a distinguished road

      0  

    Default


    okay, so is there a way to send a request for authentication from the app itself? also, i didn't get you about the auto login. (by the way, i'm still learning sencha. so i'll probably have a lot of questions )