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.
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.
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.
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"}
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
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.
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
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.
Ahh, good spot. I'll update it as soon as I have a sec.
Thanks for letting me know.
Matt
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.
Hmm, have you tried alternative casing on that one also? Could be suffering from the same thing.
Matt
If I change the parameter to be DocTypeAlias instead of doctypealias it returns all the nodes in the CMS.
is working on a reply...