-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ng-token-auth with ngResource #36
Comments
So I copied from: "Example configuration when using devise token auth" angular.module('myApp', ['ng-token-auth']) And used my own apiUrl of 'http://www.spacetools.org/api', tried to match the sample code with a full url. However, since ngResource was constructing urls like '/api/organizations.json' the $http wasn't getting the token injected into the request. Perhaps the sample above should just use '/api' ? Or else perhaps explain more? Just a thought. Otherwise, THANK YOU so much for this and the rails gem. |
Thanks, I'll make a note in the readme. |
Helped me too man! Thank you. |
Cool 👍 |
👍 |
Hey yall - I just stumbled upon this when I was having an issue using ng-resource. The path you pass in as a param to $resource has to explicitly match that of the apiUrl you provide for $authProvider. Example (didn't work for $resource, worked for $http):
It was not working because I did not include the forward slash in the beginning of the config. Fixed by changing the config to:
Hope this may help someone stuck with this. |
Yeah, we had the same problems and putting slash |
@grantgeorge So, how should I provide the
And still the headers are not being injected into the requests. |
@gowthamgts try using a relative URL, ex '/' if that's the path to the appropriate resource (see my example). Is that your question? |
@grantgeorge No pal, I have to use a fully qualified name. The headers are not injected by default, but it is working fine now after I changed the storage option to |
I might be doing something wrong but if I use ngResource methods, the token doesn't get passed to the server. If I use plain $http.get it does. Either way generates the same ajax GET call, but whatever ng-token-auth does to hook into $http doesn't seem to extend to ngResource. I tried with both latest angular 1.3rc0 and 1.2.23.
angular.module('spacetoolsApp')
.controller('OrganizationsCtrl', ['$scope', 'Organization', '$http', function ($scope, Organization, $http) {
// THIS NEXT LINE WORKS
$scope.organizations = $http.get('http://www.spacetools.org/api/organizations.json');
// THIS LINE DOESN'T SEND ACCESS TOKEN TO SERVER, THOUGH AJAX CALL IS THE SAME
$scope.organizations = Organization.query();
}]);
The text was updated successfully, but these errors were encountered: