Exemple #1
0
        private static async Task RequestModifier(ClientCredentialsGrantHandler x, HttpRequestMessage request, CancellationToken token)
        {
            var auth = request.Headers.Authorization;

            if (auth != null)
            {
                var model = await x.GetAccessTokenAsync();

                request.Headers.Authorization = new AuthenticationHeaderValue(auth.Scheme, model.AccessToken);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var handler = new ClientCredentialsGrantHandler("http://localhost:9090");

            var api = OAuth2RestClient.For <IMyApp>("http://localhost:9090", handler);

            string result = api.GetHelloAsync().Result;

            Console.WriteLine(result);

            int x = 0;
        }
Exemple #3
0
 public static T For <T>(string url, ClientCredentialsGrantHandler grantHandlerType)
 {
     return(RestClient.For <T>(url, (request, token) => RequestModifier(grantHandlerType, request, token)));
 }