Connection to windows.graph with OAuth plugin


#1

Hi,
I am trying to use nativescript-oauth plugin to use with MS windows graph API. Login and obtaining access token works. Problem is I cannot retrieve information about the logged user, I tried:

exports.loadCurrentUserProfile = function(){
    oauth.ensureValidToken().then(function(token){
        var url =  'https://graph.windows.net/me?api-version=1.6'
    http.getJSON({
        url: url,
        method: 'GET',
        headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`}
    }).then(function(result) {
        console.dir(result);
    }, function(error) {
        console.error(error);
    });
    });
};

but I am getting error message

     "odata.error": {
         "code": "Authentication_MissingOrMalformed",
         "message": {
             "lang": "en",
             "value": "Access Token missing or malformed."
         },
         "date": "2018-01-16T10:12:51",
         "requestId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
         "values": null
     }

Can you point out what I am missing?