Esempio n. 1
0
        /// <summary> Issues the access token </summary>
        /// <param name="inputParams">The input parameters</param>
        /// <returns>FlowResult with the access token</returns>
        /// <exception cref="ClientException"> Various exceptions </exception>
        public FlowResult IssueAccessToken(Parameters inputParams = null)
        {
            GrantTypIdentifier grantType;
            var param = this.GetParam("grant_type", HTTPMethod.Post, inputParams);
            if (param == null || Enum.TryParse(param.ToString(), out grantType) == false)
                throw new ClientException(HTTPErrorType.invalid_request, "grant_type");

            // Ensure grant type is one that is recognised and is enabled
            if (!this.grantTypes.ContainsKey(grantType))
                throw new ClientException(HTTPErrorType.unsupported_grant_type, grantType.ToString());

            // Complete the flow
            return this.GetGrantType(grantType).CompleteFlow(inputParams);
        }
Esempio n. 2
0
        /// <summary> Get a parameter from passed input parameters  </summary>
        /// <param name="parameters"> Required parameters  </param>
        /// <param name="method"> Get / put / post / delete  </param>
        /// <param name="inputParams"> Passed input parameters  </param>
        /// <param name="defaultValue"> The default value  </param>
        /// <returns> NameValueCollection "Null" if parameter is missing  </returns>
        public dynamic GetParam(string[] parameters, HTTPMethod method = HTTPMethod.Get, Parameters inputParams = null, string defaultValue = null)
        {
            var response = new Parameters(parameters);
            foreach (var p in parameters)
            {
                var value = this.GetParam(p, method, inputParams);
                if (value != null)
                    Impromptu.InvokeSet(response, p, value);
            }

            return response;
        }