Skip to content

Commit 65fe44b

Browse files
authored
Merge pull request #171451 from maliksahil/pubclientrediruri
Added information around default redirect uri for public client apps
2 parents c3b37b8 + fc8a5bd commit 65fe44b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

articles/active-directory/develop/msal-net-instantiate-public-client-config-options.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ Before initializing an application, you first need to [register](quickstart-regi
2828
- The tenant ID if you are writing a line of business application solely for your organization (also named single-tenant application).
2929
- For web apps, and sometimes for public client apps (in particular when your app needs to use a broker), you'll have also set the redirectUri where the identity provider will contact back your application with the security tokens.
3030

31+
## Default Reply Uri
32+
33+
In MSAL.NET 4.1+ the default redirect URI (Reply URI) can now be set with the `public PublicClientApplicationBuilder WithDefaultRedirectUri()` method. This method will set the redirect uri property of public client application to the recommended default.
34+
35+
This method's behavior is dependent upon the platform that you are using at the time. Here is a table that describes what redirect uri is set on certain platforms:
36+
37+
Platform | Redirect URI
38+
--------- | --------------
39+
Desktop app (.NET FW) | `https://login.microsoftonline.com/common/oauth2/nativeclient`
40+
UWP | value of `WebAuthenticationBroker.GetCurrentApplicationCallbackUri()`
41+
.NET Core | `http://localhost`
42+
43+
For the UWP platform, is enhanced the experience by enabling SSO with the browser by setting the value to the result of `WebAuthenticationBroker.GetCurrentApplicationCallbackUri()`.
44+
45+
For .NET Core, MSAL.Net is setting the value to the local host to enable the user to use the system browser for interactive authentication.
46+
47+
> [!NOTE]
48+
> For embedded browsers in desktop scenarios the redirect uri used is intercepted by MSAL to detect that a response is returned from the identity provider that an auth code has been returned. This uri can therefore be used in any cloud without seeing an actual redirect to that uri. This means you can and should use `https://login.microsoftonline.com/common/oauth2/nativeclient` in any cloud. If you prefer you can also use any other uri as long as you configure the redirect uri correctly with MSAL and in the app registration. Specifying the default Uri in the application registration means there is the least amount of setup in MSAL.
49+
3150

3251
A .NET Core console application could have the following *appsettings.json* configuration file:
3352

0 commit comments

Comments
 (0)