windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Retrieving a Facebook User Friends List using Auth0 and Aurelia

Asked By: Anonymous

I am using Auth0 for user authentication in my Aurelia Single Page App. I can successfully sign in and out using the code below in my app.js

login() {
  this.lock.show();   
}

And in the constructor:

this.lock.on('authenticated', (authResult) => {
     self.lock.getProfile(authResult.idToken, (error, profile) => {
        if (error) {
            // Handle error
            console.log(error);
            return;
        }

        localStorage.setItem('id_token', authResult.idToken);
        localStorage.setItem('profile', JSON.stringify(profile));
        self.isAuthenticated = true;
        self.lock.hide();
    });
}

I wish to now make a call to the Facebook Graph API and retrieve a list of the logged in user’s friends. I have already set the permission to grant access to the app for this function. I am trying to get the list of friends using this the fetch moduke like:

this.http.fetch('https://graph.facebook.com/v2.5/{user-id}/friends', {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ' + authResult.idToken
    }
})
    .then(response => response.json())
    .then(friends => this.friends = friends);

However I am receiving an error “An access token is required to request this resource”. I do not know if I am doing this properly. I have read the docs but I am stuck. I will really appreciate any help offered. Thanks guys!


Solution

Answered By: Anonymous

You need to call the Facebook API with an access token issued by Facebook instead of the Auth0 id_token issued as part of the authentication process.

Identity Provider (in this case Facebook) access tokens can be obtained after the user has authenticated with the IdP by making an HTTP GET call to the /api/v2/user/{user-id} endpoint containing an Auth0 API token generated with read:user_idp_tokens scope.

For more information about this see the topic on Identity Provider Access Tokens in the existing documentation. That page also links to a ste-by-step tutorial on how to Call an Identity Provider API.

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort http://www.kadinescort.net Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort