summaryrefslogtreecommitdiffstats
path: root/samples/OAuth2ProtectedWebApi
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OAuth2ProtectedWebApi')
-rw-r--r--samples/OAuth2ProtectedWebApi/Controllers/UserController.cs7
-rw-r--r--samples/OAuth2ProtectedWebApi/Views/User/Authorize.cshtml1
2 files changed, 6 insertions, 2 deletions
diff --git a/samples/OAuth2ProtectedWebApi/Controllers/UserController.cs b/samples/OAuth2ProtectedWebApi/Controllers/UserController.cs
index 3e673c5..e627dc2 100644
--- a/samples/OAuth2ProtectedWebApi/Controllers/UserController.cs
+++ b/samples/OAuth2ProtectedWebApi/Controllers/UserController.cs
@@ -34,10 +34,13 @@
var authRequest = await authServer.ReadAuthorizationRequestAsync(new Uri(request));
IProtocolMessage responseMessage;
if (approval) {
- responseMessage = authServer.PrepareApproveAuthorizationRequest(
+ var grantedResponse = authServer.PrepareApproveAuthorizationRequest(
authRequest, this.User.Identity.Name, authRequest.Scope);
+ responseMessage = grantedResponse;
} else {
- responseMessage = authServer.PrepareRejectAuthorizationRequest(authRequest);
+ var rejectionResponse = authServer.PrepareRejectAuthorizationRequest(authRequest);
+ rejectionResponse.Error = Protocol.EndUserAuthorizationRequestErrorCodes.AccessDenied;
+ responseMessage = rejectionResponse;
}
var response = await authServer.Channel.PrepareResponseAsync(responseMessage);
diff --git a/samples/OAuth2ProtectedWebApi/Views/User/Authorize.cshtml b/samples/OAuth2ProtectedWebApi/Views/User/Authorize.cshtml
index 0664741..930788e 100644
--- a/samples/OAuth2ProtectedWebApi/Views/User/Authorize.cshtml
+++ b/samples/OAuth2ProtectedWebApi/Views/User/Authorize.cshtml
@@ -8,6 +8,7 @@
@using (Html.BeginForm("Respond", "User", FormMethod.Post)) {
@AntiForgery.GetHtml()
@Html.Hidden("request", this.ViewData["request"])
+ <p>Are you sure you want to allow the client to access your data, with this scope: <b>@string.Join(" ", (IEnumerable<string>)ViewData["Scope"])</b></p>
<input type="submit" name="approval" value="true" />
<input type="submit" name="approval" value="false" />
} \ No newline at end of file