social-app-django icon indicating copy to clipboard operation
social-app-django copied to clipboard

redirect_uri is set to https://127.0.0.1:8001/social-auth/complete/facebook

Open juancresc opened this issue 5 years ago • 4 comments

Iḿ having an issue with a django / facebook login. When redirected to facebook I noticed that the redirect URL is set as follow:

redirect_uri=https://127.0.0.1:8001/social-auth/complete/facebook/&state=LppYImgn2B4X53ZpWunR7M3mIR6E4Rvh&return_scopes=true&scope=email

facebook complains and says the URL is not valid. Iḿ not sure where this URL comes from.

juancresc avatar May 15 '20 15:05 juancresc

I have the same problem

Bastilla123 avatar May 16 '20 20:05 Bastilla123

Add this to your settings.py

USE_X_FORWARDED_HOST = True

El El sáb, 16 may. 2020 a la(s) 17:11, Bastilla123 [email protected] escribió:

I have the same problem

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/python-social-auth/social-app-django/issues/251#issuecomment-629699910, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQK5U5E7LLHIHN67IK5NJTRR3XNRANCNFSM4NBU6YYQ .

-- Enviado con Gmail Mobile

juancresc avatar May 16 '20 20:05 juancresc

I have the same problem

i used node.js , http-proxy-middleware

i can't custom HOST in redirect_uri

ghost avatar Sep 20 '20 08:09 ghost

this url maybe help to you https://github.com/python-social-auth/social-app-django/issues/31#issuecomment-277444431

my way:

i used node.js , http-proxy-middleware

i change my Proxy setting, it's works in my project

here is my code :

old code, can't work,

i got a error : The redirect_uri MUST match the registered callback URL for this application

/* eslint-disable no-console */
const express = require('express');
const next = require('next');

const devProxy = {
  '/api': {
    target: 'http://0.0.0.0:8000/',
    changeOrigin: true,
  },

};

const port = parseInt(process.env.PORT, 10) || 3000;
const env = process.env.NODE_ENV;
const dev = env !== 'production';
const app = next({
  dir: '.', // base directory where everything is, could move to src later
  dev,
});

const handle = app.getRequestHandler();

let server;
app
  .prepare()
  .then(() => {
    server = express();

    // Set up the proxy.
    if (dev && devProxy) {
      const {createProxyMiddleware} = require('http-proxy-middleware');

      Object.keys(devProxy).forEach(function (context) {
        server.use(createProxyMiddleware(context, devProxy[context]));
      });
    }

    server.all('*', (req, res) => {
        handle(req, res);
    });

    server.listen(port, err => {
      if (err) {
        throw err;
      }
      console.log(`> Ready on port ${port} [${env}]`);
    });
  })
  .catch(err => {
    console.log('An error occurred, unable to start the server');
    console.log(err);
  });

new code, it's works for me

/* eslint-disable no-console */
const express = require('express');
const next = require('next');

const devProxy = {
  '/api': {
    target: 'http://0.0.0.0:8000/',
    changeOrigin: true,
    headers: {
      Host: 'mydomain.com',
       Origin: 'mydomain.com'
    },
  },

};

const port = parseInt(process.env.PORT, 10) || 3000;
const env = process.env.NODE_ENV;
const dev = env !== 'production';
const app = next({
  dir: '.', // base directory where everything is, could move to src later
  dev,
});

const handle = app.getRequestHandler();

let server;
app
  .prepare()
  .then(() => {
    server = express();

    // Set up the proxy.
    if (dev && devProxy) {
      const {createProxyMiddleware} = require('http-proxy-middleware');

      Object.keys(devProxy).forEach(function (context) {
        server.use(createProxyMiddleware(context, devProxy[context]));
      });
    }

    server.all('*', (req, res) => {
        handle(req, res);
    });

    server.listen(port, err => {
      if (err) {
        throw err;
      }
      console.log(`> Ready on port ${port} [${env}]`);
    });
  })
  .catch(err => {
    console.log('An error occurred, unable to start the server');
    console.log(err);
  });

what i do

just add

 headers: {
      Host: 'mydomain.com',
       Origin: 'mydomain.com'
    },

ghost avatar Sep 20 '20 09:09 ghost