Almost there. Did you forget to set up necessary environment variables for your deployment?
I have added the client id and secret of the azure application but it is as if it did not take that data. The code is as is, I have simply added the id’s
.env.sample
# Note: If you are using Azure App Service, go to your app's Configuration,
# and then set the following values into your app's "Application settings".
CLIENT_ID='430e8cf741f'
CLIENT_SECRET='Y3E8Q~PZZgY5a0CSc1X'
# The AUTHORITY variable expects a full authority URL.
#
# If you are using an AAD tenent, configure it as
# "https://login.microsoftonline.com/TENANT_GUID"
# or "https://login.microsoftonline.com/subdomain.onmicrosoft.com".
#
# If you are using a CIAM tenant, configure it as "https://subdomain.ciamlogin.com"
#
# Alternatively, leave it undefined if you are building a multi-tenant app in world-wide cloud
AUTHORITY='892241-08e56825da42'
I’m assuming that those are the sample values, since you show a file called .env.sample . At least, I’m hoping that you haven’t just published your actual IDs - if you have, go and change them now.
You need to have those as actual environment variables. Having a file called .env is a common convention, but it isn’t automatic. Often what you then need to do is source .env in your shell, but depending on how you’re set up, that might be written differently.
the ids are not the good ones, they are invented.
I have done the test and putting the values directly in app_config.py if it works.
So what happens is that app_config.py doesn’t pick them up from the .env.sample file
I have not understood very well what you are telling me.
I have created an environment following the command
It shouldn’t. What it will be looking for is a file called .env - the sample is just there as, well, a sample. Try copying that to .env and seeing whether it now reads those variables.
Unfortunately, the name “environment” has many meanings, but the Python “Virtual Environment” has nothing to do with “environment variables” which are the problem here.
At the moment it doesn’t work for me… but I happen to have another problem.
Previously, I had a multi-tenant position and now I have a single tenant position.
Well it gives me an error
invalid_client
AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented. Trace ID: 0f0600 Correlation ID: 0a2cf92d Timestamp: 2023-08-01 11:38:36Z
I don’t know if I’m putting the data where it should be AUTHORITY = "https://login.microsoftonline.com/<tenant id>"
Finally I solved the azure issue but continuing with the thread of the main problem, I don’t finish making it work, it still doesn’t take the values of the .env file from app_config.py
Ah okay, did you pip install -r requirements.txt? It includes python-dotenv, and Flask only picks up env values from .env is python-dotenv is installed.