title: problems trying to use the Instagram api
body: <p>I am working with Angular and Node.js with Express.js. I have all day trying to get the posts from my Instagram account but I have not even been able to get the API token. I understand that you first have to make a request to this URL: <code>https://api.instagram.com/oauth/authorize?client_id=[instagram-app-id-lex.europa.eu&amp;redirect_uri=[redirect-uriíritu&amp;scope=[scope-lex.europa.eu&amp;response_type=code&amp;state = {state}</code> (replacing the id and redirect-uri obviously) but I get no response. I already created my app in the instagram api following its documentation and add the tester and accept the authorization from the account settings.</p>
  <p>At the moment I have this code en node.js:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const instagram = require('../controllers/instagram/instagram.controller');
  const route = '/auth'
  
  
  module.exports= (app,db, protegerRutas)=&gt; {
  
      app.get(`${route}/instagram`, (req, res)=&gt; instagram.auth(req, res));
  
      app.get(`/handle`, (req,res)=&gt; instagram.handleauth(req,res));
  
      // app.get(`${}`)
      // app.post(`${route}/actualizar`, protegerRutas, (req, res)=&gt; actualizar.actualizarDatos(req, res, db))
  }</code></pre>
  </div>
  </div>
  </p>
  <p>controller:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const Instagram = require('node-instagram').default;
  const axios = require('axios');
  const clavesInstagram = require('../../config/config').instagram;
  
  const {clientId, clientSecret}= clavesInstagram;
  const urlInstagram = 'https://api.instagram.com/oauth/authorize?client_id=201577004938695&amp;redirect_uri=https://localhost:3008/auth/handle&amp;scope={scope}&amp;response_type=code';
  const redirectUri = 'https://b4ae544459e3.ngrok.io/handle';
  
  const instagram = new Instagram({
      clientId: clientId,
      clientSecret: clientSecret
  })
  
  module.exports= {
  
      auth: (req,res)=&gt; {
          axios.get(urlInstagram)
              .then( res =&gt; {
                  console.log('\n\nRespuesta: ',res);
              })
              .catch( err =&gt; {
                  console.log('\n\nError: ',err);
              })
      },
  
      // auth: (req, res)=&gt; {
      //  console.log('\n\nAuth Controller...')
      //  res.redirect(
      //      instagram.getAuthorizationUrl(redirectUri, {
      //          scope: ['basic','likes'],
      //          state: 'your state'
      //      })
      //  )
      // },
  
      handleauth: async (req, res)=&gt; {
          try {
              console.log('\n\n\n\nHandleAuth....\n\n\n\n\n')
              const code = req.query.code; //código devuelto por Instagram
              const data= await instagram.authorizeUser(code, redirectUri);
              console.log('\n\nData Instagram:', data)
              res.json(data);
              
          } catch(e) {
              // statements
              console.log(e);
              res.json(e)
          }
      }
  
  }</code></pre>
  </div>
  </div>
  </p>
  <p>I understand that in the instagram API configuration the URL of my app is added to which they redirect and send the token, the url of my local app is something like this: <code>http://localhost:3008/</code> and the path to which I want instagram to redirect would be this: <code>https://localhost:3008/auth/handle</code> (I must put it with 'https' in instagram because it does not allow http, so I don't know if this would include me). The problem is that with this code I am not getting the token that should be sent to my route <code>https://localhost:3008/auth/handle</code>. What am I doing wrong? I've been at this for many hours and honestly I can't find a solution. I read the documentation and try to do what it says but I can't do it. Could someone help me with this? I would be enormously grateful.</p>
  <p>Thanks in advance.</p>