Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris 8 posts 26 karma points
    Jan 09, 2012 @ 15:00
    Chris
    0

    Token Error

                $.ajax({

                    type: 'POST',

                    url: 'http://app.local/rest/token',

                    data: { 'Username': username, 'Password': password, 'Type': 'User' },

                    success: function (d) { alert(d); },

                    dataType: 'json'

                }).error(function (error) { debugger; alert(error); });

     

    Any Idea?

     

    Returns {"Username":null,"Password":null,"Type":0,"Value":"f4ffdafb9df6162a27620b7c4a78042cd177aa5b"}

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Jan 09, 2012 @ 15:03
    Matt Brailsford
    0

    Hi Chris,

    That is the expected response. The token method takes a username and password and creates a token, returned in the "Value" property, to use when accessing other uRest methods.

    Matt

  • Chris 8 posts 26 karma points
    Jan 09, 2012 @ 16:24
    Chris
    0

    Cool, now making the request rest/documents/3704?auth_username=Administrator&auth_token=f4ffdafb9df6162a27620b7c4a78042cd177aa5b

    $.get('/rest/documents/3704', { 'auth_username': username, 'auth_token': token },

                            function (data) {

                                alert(data);

                            }, 'json');

     

    gives me a 403 error.

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Jan 09, 2012 @ 16:36
    Matt Brailsford
    0

    Hi Chris,

    The token method only returns a tokenized string to use in authenticating your requests, it doesn't meen it's a valid login, so the fact you are receiving a 403 would suggest that the username and/or password that you are using isn't valid.

    Checkout the AuthorizeInterceptor for the logic that is run on every request to validate the credentials.

    http://urest4umb.codeplex.com/SourceControl/changeset/view/338746fc4def#Src%2fuREST.Core%2fInterceptors%2fUmbracoAuthorizeInterceptor.cs

    Matt

    PS There are full docs on the codeplex site aswell

    http://urest4umb.codeplex.com/documentation

  • Chris 8 posts 26 karma points
    Jan 09, 2012 @ 17:11
    Chris
    0

    Ok, I found the error, my creditials were correct, however your code is not ignoring the case sensitivity of the username. The username has to be all lowered case for it to work currently.

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Jan 09, 2012 @ 17:21
    Matt Brailsford
    0

    Ahh, good spot. I'll update it as soon as I have a sec.

    Thanks for letting me know.

    Matt

  • Chris 8 posts 26 karma points
    Jan 09, 2012 @ 17:37
    Chris
    0

    No worries, I''m also experiencing a second problem.

    http://myapp/rest/documents?auth_username=administrator&auth_token=my_token&doctypealias=Announcement

    I have nodes with that doc type, however, the services is returning empty results.

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Jan 09, 2012 @ 17:58
    Matt Brailsford
    0

    Hmm, have you tried alternative casing on that one also? Could be suffering from the same thing.

    Matt

  • Chris 8 posts 26 karma points
    Jan 09, 2012 @ 18:05
    Chris
    0

    If I change the parameter to be DocTypeAlias instead of doctypealias it returns all the nodes in the CMS.

Please Sign in or register to post replies

Write your reply to:

Draft