public ViewResult ClientCredentialsGrant(ClientCredentialsGrantViewModel model) { if (this.ModelState.IsValid) { try { // Create the client with which we will be connecting to the server. var webServerClient = new WebServerClient(this.AuthorizationServerDescription, clientIdentifier: model.ClientId, clientSecret: model.ClientSecret); // The scope that we request for the client. Note: this can also be null if we don't want to request any specific // scope or more than one scope if we want to request an access token that is valid for several scopes var clientScopes = OAuthUtilities.SplitScopes(model.Scope ?? string.Empty); // Request a new client access token for the specified scopes (http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.4) // This method will use the client identifier and client secret used when constructing the WebServerAgentClient instance this.ViewBag.AccessToken = webServerClient.GetClientAccessToken(clientScopes); } catch (Exception ex) { this.ViewBag.Exception = ex; } } return this.View(model); }
public ViewResult ClientCredentialsGrant() { // We will set-up correct default values to make it easier for the user to start testing var model = new ClientCredentialsGrantViewModel { ClientId = "demo-client-identifier", ClientSecret = "demo-client-secret", Scope = "demo-client-scope" }; return this.View(model); }