|
1 | | -using IdentityServer4.Models; |
2 | | -using Microsoft.Extensions.Options; |
| 1 | +using IdentityServer4; |
| 2 | +using IdentityServer4.Models; |
3 | 3 | using System.Collections.Generic; |
4 | | -using IdentityServer4; |
5 | 4 |
|
6 | 5 | namespace Identity.API.Configuration |
7 | 6 | { |
@@ -56,19 +55,26 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr |
56 | 55 | { |
57 | 56 | ClientId = "xamarin", |
58 | 57 | ClientName = "eShop Xamarin OpenId Client", |
59 | | - AllowedGrantTypes = GrantTypes.Implicit, |
60 | | - AllowAccessTokensViaBrowser = true, |
61 | | - RedirectUris = { clientsUrl["Xamarin"] }, |
| 58 | + AllowedGrantTypes = GrantTypes.Hybrid, |
| 59 | + //Used to retrieve the access token on the back channel. |
| 60 | + ClientSecrets = |
| 61 | + { |
| 62 | + new Secret("secret".Sha256()) |
| 63 | + }, |
| 64 | + RedirectUris = { clientsUrl["Xamarin"] }, |
62 | 65 | RequireConsent = false, |
63 | 66 | PostLogoutRedirectUris = { $"{clientsUrl["Xamarin"]}/Account/Redirecting" }, |
64 | | - AllowedCorsOrigins = { "http://eshopxamarin" }, |
65 | | - AllowedScopes = |
| 67 | + AllowedCorsOrigins = { "http://eshopxamarin" }, |
| 68 | + AllowedScopes = new List<string> |
66 | 69 | { |
67 | 70 | IdentityServerConstants.StandardScopes.OpenId, |
68 | 71 | IdentityServerConstants.StandardScopes.Profile, |
| 72 | + IdentityServerConstants.StandardScopes.OfflineAccess, |
69 | 73 | "orders", |
70 | 74 | "basket" |
71 | | - } |
| 75 | + }, |
| 76 | + //Allow requesting refresh tokens for long lived API access |
| 77 | + AllowOfflineAccess = true |
72 | 78 | }, |
73 | 79 | new Client |
74 | 80 | { |
@@ -96,7 +102,7 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr |
96 | 102 | IdentityServerConstants.StandardScopes.Profile, |
97 | 103 | IdentityServerConstants.StandardScopes.OfflineAccess, |
98 | 104 | "orders", |
99 | | - "basket", |
| 105 | + "basket" |
100 | 106 | }, |
101 | 107 | } |
102 | 108 | }; |
|
0 commit comments