google oauth 2.0 redirect_uri_mismatch (aws ec2 + route53 + nginx + uwgsi + flask + socketio)

383
September 11, 2017, at 12:15 PM

I am getting a redirect_uri_mismatch whenever I try to use Google OAuth 2.0 on my website. I am using aws ec2 + route53 + nginx + uwgsi + flask + socketio

The Authorized redirect URIs: Had to add parenthesis to remove link.

  • (http)://example.net/auth/oauth2callback
  • (http)s://example.net/auth/oauth2callback
  • (http)://www.example.net/auth/oauth2callback
  • (http)s://www.example.net/auth/oauth2callback
  • (http)://localhost/auth/oauth2callback
  • (http)s://localhost/auth/oauth2callback

I've added a trailing "/" as well, but it doesn't seem to fix anything. I suspect its an nginx server setting issue or some connection issue between nginx -> uwsgi -> flask since the redirect uri what google's error page tells me exactly matches the URIs I've put into Google's OAuth settings.

Here is my nginx server configuration:

server {
    listen 80;
    server_name www.example.net;
    return 301 http://example.net;
}
server {
    listen 80;
    server_name example.net;
    return 301 https://example.net;
}
server {
    listen 443;
    server_name example.net;
    ssl on;
    ssl_certificate /certs.pem;
    ssl_certificate_key /private.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers BLANK;
    ssl_session_cache shared:SSL:50m;
    ssl_dhparam /dhparam.pem;
    ssl_prefer_server_ciphers on;
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/filename.sock;
    }
}

I've looked into a lot of documents regarding this. Most people uses proxies and had to add some lines into the server configuration to handle this issue, but since I am not using such, I believe I don't have to put any of those in my configuration. (I tried a few solutions just in case, but they didn't seem to fix it still.)

Without using nginx and uwsgi, I was able to get the OAuth feature to work on localhost.

Thanks in advance!

READ ALSO
Efficiently record and store page view counts in Django? [on hold]

Efficiently record and store page view counts in Django? [on hold]

How can I count & store the Page views in Django?

166
Find and display links to specified URLs using regex

Find and display links to specified URLs using regex

So I am trying to extract only links to particular sitesI have written the following by sifting through this site for hours now, but it does not work great for me

213
What is wrong with my print function?

What is wrong with my print function?

[enter image description here][1]I am in an introduction to Anaconda class and I need to write a program to determine how many times a dice roll(s) land on a certain amount of facesHowever, I cannot get it to print my answer correctly: Here is my script...

235
I'm trying to pass usernames to excel using praw I get: AttributeError: 'list' object has no attribute 'to_excel

I'm trying to pass usernames to excel using praw I get: AttributeError: 'list' object has no attribute 'to_excel

I am trying to run analysis on a subreddit by usersWhen I try to send the the data (df) to excel I get this error: AttributeError: 'list' object has no attribute 'to_excel

276