Beispiel #1
0
        private IList <NameValuePair> GetPostParams(ResourceScopedAccessGrantParameters grantParameters)
        {
            var parameters = new List <NameValuePair>()
            {
                new NameValuePair("resource", grantParameters.Resource)
            };

            if (grantParameters.TenantId != null)
            {
                parameters.Add(new NameValuePair("tenantId", grantParameters.TenantId));
            }

            var amr = grantParameters.AmrString;

            if (amr != null)
            {
                parameters.Add(new NameValuePair("amr", amr));
            }

            return(parameters);
        }
Beispiel #2
0
        /// <summary>
        /// Retrieve access token for the configured "client_id", specified scope and resource
        /// </summary>
        /// <param name="parameters">Custom grant parameters</param>
        /// <param name="token">Cancellation token</param>
        /// <returns>Access token</returns>
        /// <exception cref="TokenEndpointException">Exception during token endpoint communication</exception>
        public async Task <string> GetTokenAsync(ResourceScopedAccessGrantParameters parameters, CancellationToken token = default(CancellationToken))
        {
            var result = await _customGrantTokenClient.GetTokenInternalAsync(GetPostParams(parameters), new [] { parameters.Scope }, token).ConfigureAwait(false);

            return(result.Item1);
        }