microsoftgraph / aspnetcore-connect-sample

[ARCHIVED] This ASP.NET Core MVC sample shows how to connect to Microsoft Graph using delegated permissions and the Azure AD v2.0 (MSAL) endpoint.
MIT License
123 stars 96 forks source link

Application using http vs https #50

Closed JeffPerrin-AP closed 4 years ago

JeffPerrin-AP commented 5 years ago

I have followed the example application and have it working in localhost, when I publish it to my web server I get errors about the redirect_uri not matching. I am redirecting to https:// but when I inspect the request I see that the library is setting the query string parameters to http.

How can I get the library to only try over https?

Request URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=2ccc9d31-acab-4dd7-bb01-e8d72af2a1c0&redirect_uri=http%3A%2F%2Fomitted%2Fsignin-oidc&response_type=code%20id_token&scope=openid%20profile%20email%20offline_access%20User.ReadBasic.All%20User.Read%20Group.Read.All%20Directory.Read.All&response_mode=form_post&nonce=637025275025380855.MzY4ZDgyMzItODcyNi00MWEyLTg2MDItMzMxZDY5NDEzNzgwNDgzNzZiNjItNGEwZC00M2YzLWI5NWMtNzBiYTkyOGI2YzAx&state=CfDJ8M0SXndj4gNBrBEmxumC0xg8xGFNDbosr_HUFaTwe1bwhIvU185ZodrLs2b--_vwpbiCf69mUnNwv5324lrhFUqrfGRc1dJdzphv1LbO5YL8_9X3hPACAZOZBNl8vWh6VMaUNNL2j8vC7_98VfLVXdg2dpAqEjgpAN8her9RH2Geg4yg5JfLUYUFccZqhTlIZIuVhq2rH1jR3LxvZ0GxG60o3GV3Ni0Zbe-t1KfobKZahOTSc6jes5qObmnhItHOK5EPRglCk1gzo86j57y6MMO_YyN6v5aq8ZddxBQjgqPje3MJ_iCBwtcAF0GzHIytYc222JJVcDMf6oEIRqbxgfO0CxfmaUin3T4XcTavIKvs&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=5.3.0.0&sso_reload=true

mark-szabo commented 5 years ago

Hi, have you added the url of the server where you have published your app to the application registration in AAD?

JeffPerrin-AP commented 5 years ago

Yes, its configured, AAD only allows addresses starting with https and the app keeps trying to redirect to http.

pschaeflein commented 5 years ago

The redirectUri is set in the GraphAuthProvider class, which reads it from appsettings.json. .WithRedirectUri(azureOptions.BaseUrl + azureOptions.CallbackPath)

(The value sent in the request should match what is specified in the registration in AAD.)