Skip to content

Commit

Permalink
Merge pull request #74 from Azure-Samples/jmprieur/defaultRedirectUri
Browse files Browse the repository at this point in the history
changing the default redirect URI in subfolders 2. and 3.
  • Loading branch information
jmprieur authored Jul 12, 2019
2 parents 0b52cc2 + 4674891 commit 58c2213
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 2. Web API now calls Microsoft Graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ If you want to register your apps manually, as a first step you'll need to:
- Select **Register** to create the application.
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the Visual Studio configuration file for this project (`ida:ClientId` in `TodoListClient\App.Config`).
1. From the app's Overview page, select the **Authentication** section.
1. In the **Redirect URIs** list, select for **TYPE** Public client (mobile & desktop). Then paste this value **urn:ietf:wg:oauth:2.0:oob** in the **REDIRECT URI** column.
1. In the **Redirect URIs** list, under **Suggested Redirect URIs for public clients (mobile, desktop)** check the box next to **https://login.microsoftonline.com/common/oauth2/nativeclient**.
1. Select **Save**.
1. Select the **API permissions** section
- Click the **Add a permission** button and then,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public MainWindow()
InitializeComponent();
_app = PublicClientApplicationBuilder.Create(ClientId)
.WithAuthority(Authority)
.WithDefaultRedirectUri()
.Build();

TokenCacheHelper.EnableSerialization(_app.UserTokenCache);
Expand Down Expand Up @@ -221,7 +222,8 @@ await _app.AcquireTokenInteractive(scopes)
else if (proposedAction == "consent")
{
IPublicClientApplication pca = PublicClientApplicationBuilder.Create(clientId)
.Build();
.WithDefaultRedirectUri()
.Build();
await pca.AcquireTokenInteractive(scopes)
.WithPrompt(Prompt.Consent)
.WithLoginHint(loginHint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ What **differs from the previous chapter** is that you will use the same applica

1. On the app **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the Visual Studio configuration file for this project (`ida:ClientId` in `TodoListClient\App.Config`).
1. From the app's Overview page, select the **Authentication** section.
- In the **Redirect URLs** | Add the following redirect URI: **urn:ietf:wg:oauth:2.0:oob**
- In the **Redirect URIs** list, under **Suggested Redirect URIs for public clients (mobile, desktop)** check the box next to **https://login.microsoftonline.com/common/oauth2/nativeclient**.
- Select **Save**.

### Step 3: Configure the sample to use your Azure AD tenant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public MainWindow()
InitializeComponent();
_app = PublicClientApplicationBuilder.Create(ClientId)
.WithAuthority(Authority)
.WithDefaultRedirectUri()
.Build();

TokenCacheHelper.EnableSerialization(_app.UserTokenCache);
Expand Down Expand Up @@ -221,6 +222,7 @@ await _app.AcquireTokenInteractive(scopes)
else if (proposedAction == "consent")
{
IPublicClientApplication pca = PublicClientApplicationBuilder.Create(clientId)
.WithDefaultRedirectUri()
.Build();
await pca.AcquireTokenInteractive(scopes)
.WithPrompt(Prompt.Consent)
Expand Down

0 comments on commit 58c2213

Please sign in to comment.