0

I'm working on some test app, that uses auth0 and IONIC. I have established connection with auth0, and now i want to get user data by this code:

$http({
      method: 'GET',
      url: 'https://api.instagram.com/v1/users/self/?access_token='+store.get('accessToken')
    }).then(function successCallback(response) {
        console.log(response);
      }, function errorCallback(response) {
          console.log(response);
      });

I get 400 Access-Control-Allow-Origin error. Can anybody tell me what to do? I can't find anythink on internet that'll help me...

Michał Poreda
  • 97
  • 1
  • 2
  • 8

1 Answers1

0

Disclosure: I work for Auth0

The AccessToken returned at the end of Auth0 Login flow is an access token valid for calling Auth0's API's and not Instagrams. In order to do this you will need the Identity Provider's access token in this case that is Instagram.

The complete flow will look like the following

  • User Logs in from Instagram
  • Your IONIC app makes a call to your server
  • Your server fetches the IdP Access Tokens from Auth0 using either a non-interactive client flow or using management api v2
  • Your server makes the call to Instagram

You can do this via a webtask the following example highlights the flow to fetch the IdP Access Token via Management API v2 https://github.com/vikasjayaram/ext-idp-api-webtask

I am suggesting the flow because Starting Aug 16 2016 these tokens will not be sent back in profile.identities array the as they are so far.

ShrekOverflow
  • 6,795
  • 3
  • 37
  • 48