0

I have two separated apps (AngularJS + Express + NodeJS) and a Ruby on Rails API (rails-api).

To keep it simple my client application will not authenticate users but it will need to consume the data from api.

I've used authenticate_with_http_token method in the rails-api and it works (if you pass in header or query params) but I can't retrieve the token as a security form (from environment variable I think) inside the angularjs app. Yes I can access the env vars from express server, but I can't share this values to be used at angular.

App.run(function($http ...) {
  // $http.defaults.headers.common.Authorization = proccess.env.AUTH_TOKEN_API <- I can't do this. But is something like this I need.
  $http.defaults.headers.common.Authorization = 'Token token=78db1w26vve20aa36...';

How to keep security in api in this case?

Bruno Casali
  • 1,339
  • 2
  • 17
  • 32
  • 1
    Maybe this module https://github.com/auth0/angular-jwt and this question helps you http://stackoverflow.com/questions/23244809/angular-js-set-token-on-header-default. In both cases a provider is configured so the $http service perform the request with the token. – mariowise May 07 '16 at 15:00
  • Thanks so much for your comment, I will try it and I will keep you informed! :D – Bruno Casali May 07 '16 at 21:46

0 Answers0