/// <summary>
 /// Acquires an access token for this application (usually a Web API) from the authority configured in the application,
 /// in order to access another downstream protected Web API on behalf of a user using the OAuth 2.0 On-Behalf-Of flow.
 /// See https://aka.ms/msal-net-on-behalf-of.
 /// This confidential client application was itself called with a token which will be provided in the
 /// <paramref name="userAssertion">userAssertion</paramref> parameter.
 /// </summary>
 /// <param name="scopes">Scopes requested to access a protected API</param>
 /// <param name="userAssertion">Instance of <see cref="UserAssertion"/> containing credential information about
 /// the user on behalf of whom to get a token.</param>
 /// <returns>A builder enabling you to add optional parameters before executing the token request</returns>
 /// <remarks>You can also chain the following optional parameters:
 /// <see cref="AbstractAcquireTokenParameterBuilder{T}.WithExtraQueryParameters(Dictionary{string, string})"/>
 /// </remarks>
 public AcquireTokenOnBehalfOfParameterBuilder AcquireTokenOnBehalfOf(
     IEnumerable <string> scopes,
     UserAssertion userAssertion)
 {
     return(AcquireTokenOnBehalfOfParameterBuilder.Create(
                ClientExecutorFactory.CreateConfidentialClientExecutor(this),
                scopes,
                userAssertion));
 }
Exemple #2
0
        /// <inheritdoc />
        public AcquireTokenOnBehalfOfParameterBuilder AcquireTokenInLongRunningProcess(
            IEnumerable <string> scopes,
            string longRunningProcessSessionKey)
        {
            if (string.IsNullOrEmpty(longRunningProcessSessionKey))
            {
                throw new ArgumentNullException(nameof(longRunningProcessSessionKey));
            }

            return(AcquireTokenOnBehalfOfParameterBuilder.Create(
                       ClientExecutorFactory.CreateConfidentialClientExecutor(this),
                       scopes,
                       longRunningProcessSessionKey));
        }
        /// <summary>
        /// Acquires an access token for this application (usually a Web API) from the authority configured in the application,
        /// in order to access another downstream protected web API on behalf of a user using the OAuth 2.0 On-Behalf-Of flow.
        /// See https://aka.ms/msal-net-on-behalf-of.
        /// This confidential client application was itself called with a token which will be provided in the
        /// <paramref name="userAssertion">userAssertion</paramref> parameter.
        /// </summary>
        /// <param name="scopes">Scopes requested to access a protected API</param>
        /// <param name="userAssertion">Instance of <see cref="UserAssertion"/> containing credential information about
        /// the user on behalf of whom to get a token.</param>
        /// <returns>A builder enabling you to add optional parameters before executing the token request</returns>
        /// <remarks>You can also chain the following optional parameters:
        /// <see cref="AbstractAcquireTokenParameterBuilder{T}.WithExtraQueryParameters(Dictionary{string, string})"/>
        /// </remarks>
        public AcquireTokenOnBehalfOfParameterBuilder AcquireTokenOnBehalfOf(
            IEnumerable <string> scopes,
            UserAssertion userAssertion)
        {
            if (userAssertion == null)
            {
                ServiceBundle.ApplicationLogger.Error("User assertion for OBO request should not be null");
                throw new MsalClientException(MsalError.UserAssertionNullError);
            }

            return(AcquireTokenOnBehalfOfParameterBuilder.Create(
                       ClientExecutorFactory.CreateConfidentialClientExecutor(this),
                       scopes,
                       userAssertion));
        }
Exemple #4
0
        /// <inheritdoc />
        public AcquireTokenOnBehalfOfParameterBuilder InitiateLongRunningProcessInWebApi(
            IEnumerable <string> scopes,
            string userToken,
            ref string longRunningProcessSessionKey)
        {
            if (string.IsNullOrEmpty(userToken))
            {
                throw new ArgumentNullException(nameof(userToken));
            }

            UserAssertion userAssertion = new UserAssertion(userToken);

            if (string.IsNullOrEmpty(longRunningProcessSessionKey))
            {
                longRunningProcessSessionKey = userAssertion.AssertionHash;
            }

            return(AcquireTokenOnBehalfOfParameterBuilder.Create(
                       ClientExecutorFactory.CreateConfidentialClientExecutor(this),
                       scopes,
                       userAssertion,
                       longRunningProcessSessionKey));
        }