GetAuthorizationCode() public method

Gets the authorization code.
public GetAuthorizationCode ( string clientId, AuthorizationServerIdentity delegatedIdentity, string scope ) : string
clientId string The client id.
delegatedIdentity AuthorizationServerIdentity The delegated identity.
scope string The scope.
return string
Exemplo n.º 1
0
        public virtual ActionResult Index_Post(AuthorizationServerViewModel model)
        {
            var message = TempData[OauthMessageKey] as OAuthMessage;

            if (model.Authorize)
            {
                string code = ApplicationRegistrationService.GetAuthorizationCode(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]);
                if (code != null)
                {
                    return(Redirect(message.GetCodeResponseUri(code)));
                }
                else
                {
                    return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "Error generating Authorization code. Please check if the Service Identity and the Replying Party are correct.")));
                }
            }
            else
            {
                return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "The end user has denied consent to access the requested resource")));
            }
        }
        public virtual ActionResult Index_Post(AuthorizationServerViewModel model)
        {
            var message = StoreIncomingRequest(HttpContext);

            if (message != null && message.Parameters[OAuthConstants.GrantType] == OAuthConstants.AccessGrantType.ClientCredentials)
            {
                string code = ApplicationRegistrationService.GetAuthorizationCode(message.Parameters[OAuthConstants.ClientId], GetDelegatedIdentity(), message.Parameters[OAuthConstants.Scope]);
                if (code != null)
                {
                    return(Redirect(message.GetCodeResponseUri(code)));
                }
                else
                {
                    return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.AccessDenied, "Error generating Authorization code. Please check if the Service Identity and the Replying Party are correct.")));
                }
            }
            else
            {
                return(Redirect(message.GetErrorResponseUri(OAuthConstants.ErrorCode.UnsupportedGrantType, "The provided grant type is not supported by this endpoint")));
            }
        }