http://localhost/**
for local development or your domain name
once you have deployed your application.
Open bp_auth.py
:
.env
file.
Now let’s look at the routes managing the authentication. If a user tries to access a route, which he is not authorized to
use, or manually clicks the sign-up button, he will be redirected to “/authenticate”.
authorize_redirect
function. To it, we pass a callback URL, which
consists of our host, the “/callback” route and a “next” query parameter which displays where the user was planning to
go originally. This callback URL HAS to match the pattern, that we provided in our OAuth application settings, since GitHub
doesn’t want the user to be sent to malicious sites, if the secret keys are compromised.
Once the user has logged in, he is redirected to our “/callback” route. Note, that besides the “next”
query parameter we provided, GitHub also added a “code” one. This is a token which, together with the client secret, we can
exchange for an access token. This access token is “like an API key” and allows us to fetch data about the user like his email.
req.py
file, you can see the two functions performing these actions.
add_user
function which will save this user to our database. Read the next chapter to
learn how