Auth http: No JWT present or has expired

I know there is a lot on different forums on this issue. I looked here, on Auth0 forum and on stackoverflow.

When I’m trying to make an api call I get the response 401 (Unauthorized): No JWT present or has expired.

in my app.module.ts, above @ngmodule I have an getAuthHttp function:

export function getAuthHttp(http) {
    return new AuthHttp(new AuthConfig({
        headerPrefix: 'bearer',
        noJwtError: true,
        globalHeaders: [{'Accept': 'application/json'}],
        tokenGetter: (() => JSON.parse(window.localStorage.getItem('id_token'))),
    }), http);
}

(I tried to fix tokengetter by getting token from localstorage instead of creating new storage as is suggested in some official documentation)

this is my providers array:

providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    {provide: AuthHttp, useFactory: getAuthHttp, deps: [Http] },
    AUTH_PROVIDERS,
    ChallengeService, SettingsService, UserdataService, AuthService
  ]

and of course I have an authservice file which handles login and logout and probaly more which I don’t use at the moment.

My service which calls the api:

import { Injectable} from '@angular/core';
import { AuthService} from "./auth.service";
import { AuthHttp } from "angular2-jwt";
import 'rxjs/Rx';

@Injectable()
export class MessageService{

    http: any;
    messages: any;
    authService: any;
    
    constructor(authService:AuthService, private authHttp:AuthHttp){
        this.storage = storage;
        this.authService = authService;
        this.authHttp = authHttp;
    }

    getMessage(level, location)
    {
        this.messages=  this.authHttp.get('http://10.0.2.2:8080/api/message/1');

        return this.messages;
    }
};

Now this goes wrong, obviously.

I 'm pretty sure i’m forgetting something but i can’t pinpoint it and after days of getting closer now i’m totally stuck. Who can help me fix this? I would also be okay with just using angular http but I cannot get it working with sending the headers myself as well.

My system:

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : not installed

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3 browser 4.1.0 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.11.4
npm  : 5.4.2
OS   : Windows 10

Misc:

backend : pro

I’m facing the same issue, did you ever solve this?