Force SSL in Flask

So - I’m trying to set up a Google Oauth2 authentication routine in Flask (I know, I’m a hipster) but am having some trouble with enforcing the SSL required through Flask.

When I try ssl_context="adhoc" I just get a Repl that wont’ actually get into Webview

Here’s a sample project just to demonstrate the SSL enforcement isn’t working:

Any help would be appreciated fellow Repliters! :sweat_smile:

It doesn’t seem the link you sent ( is public.

:person_facepalming: Apologies, should be public now and good to go

Is this the error you see on your end?

That’s the one, I’m sure I’m just being a muppet

Try updating you code to:

from flask import Flask
import cryptography

app = Flask(__name__)

def index():
    return 'Hello from Flask!''', port=8100)

THis doesn’t enforce https - so my Google OAuth Post commands end up going plaintext

I’m not sure then… sorry.

1 Like

@ShaneAtReplit any thoughts my friend?

Hmm, that is indeed very perculiar… Are you making requests to your server internally?

Hey @DavidAtReplit!

I’m so sorry for missing this.

From what I gathered online, ssl_context="adhoc" uses a self-signed SSL certificate, which might be why our webview isn’t working with it. However, your hosted website should always have SSL since we automatically provide a certificate for both and

If you were having issues when omitting the ssl_contextoption, can you elaborate on that so i can try to reproduce or understand the issue better?