Example #1
0
 public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 {
     token.AuthorizeRequest((tokenType, tokenValue) => {
         request.Headers.Authorization = new AuthenticationHeaderValue(tokenType, tokenValue);
     });
     return(base.ProcessHttpRequestAsync(request, cancellationToken));
 }
Example #2
0
        /// <summary>
        /// Get the token string from the accesstoken
        /// </summary>
        /// <param name="accessToken">the token</param>
        /// <returns>token string</returns>
        private string GetTokenStrFromAccessToken(IAccessToken accessToken)
        {
            var tokenStr = string.Empty;

            accessToken.AuthorizeRequest((tokenType, tokenValue) =>
            {
                tokenStr = tokenValue;
            });
            WriteDebug(DateTime.Now.ToString() + ": token:" + tokenStr);
            return(tokenStr);
        }
Example #3
0
 void VerifyToken(IAccessToken checkToken, string expectedAccessToken, string expectedUserId, string expectedTenant)
 {
     Assert.True(checkToken is RawAccessToken);
     Assert.Equal(expectedAccessToken, checkToken.AccessToken);
     Assert.Equal(expectedUserId, checkToken.UserId);
     Assert.Equal(expectedTenant, checkToken.TenantId);
     checkToken.AuthorizeRequest((type, token) =>
     {
         Assert.Equal(expectedAccessToken, token);
         Assert.Equal("Bearer", type);
     });
 }
 public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 {
     return(Task.Run(() => _token.AuthorizeRequest((type, token) => request.Headers.Authorization = new AuthenticationHeaderValue(type, token))));
 }