{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityModel/IdentityModel/issues/60","repository_url":"https://api.github.com/repos/IdentityModel/IdentityModel","labels_url":"https://api.github.com/repos/IdentityModel/IdentityModel/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/IdentityModel/IdentityModel/issues/60/comments","events_url":"https://api.github.com/repos/IdentityModel/IdentityModel/issues/60/events","html_url":"https://github.com/IdentityModel/IdentityModel/issues/60","id":187934403,"number":60,"title":"Using RefreshTokenHandler with HttpClient makes calling GetAsync(\"\").Result deadlock","user":{"login":"janobrestad","id":10034620,"avatar_url":"https://avatars.githubusercontent.com/u/10034620?v=3","gravatar_id":"","url":"https://api.github.com/users/janobrestad","html_url":"https://github.com/janobrestad","followers_url":"https://api.github.com/users/janobrestad/followers","following_url":"https://api.github.com/users/janobrestad/following{/other_user}","gists_url":"https://api.github.com/users/janobrestad/gists{/gist_id}","starred_url":"https://api.github.com/users/janobrestad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janobrestad/subscriptions","organizations_url":"https://api.github.com/users/janobrestad/orgs","repos_url":"https://api.github.com/users/janobrestad/repos","events_url":"https://api.github.com/users/janobrestad/events{/privacy}","received_events_url":"https://api.github.com/users/janobrestad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-08T08:54:28Z","updated_at":"2016-11-08T14:32:54Z","closed_at":null,"body":"Passing an instance of RefreshTokenHandler to HttpClient makes calling GetAsync synchronously by using .Result cause a deadlock. \r\n\r\nExample code: \r\n```\r\nRefeshTokenHandler rth = new RefeshTokenHandler(\"https://demo.identityserver.io/connect/token\", \r\n\"clientId\", \"clientSecret\", \"refreshToken\");\r\n\r\nHttpClient client = new HttpClient(rth);\r\nvar res = client.GetAsync(\"https://demo.identityserver.io/api/test\").Result;\r\n```\r\nThis code will deadlock when used in a non async method in Windows Forms or WPF.\r\n\r\nUsing just the HttpClient without the RefeshTokenHandler is not deadlocking:\r\n```\r\nHttpClient client = new HttpClient();\r\nclient.SetBearerToken(\"accessToken\");\r\nvar res = client.GetAsync(\"https://demo.identityserver.io/api/test\").Result;\r\n```\r\n\r\nAdding ConfigureAwait(false) to the calls to base.SendAsync in the SendAsync method in RefeshTokenHandler seems to make the deadlock go away for the simple case where you don't need to refresh the token.\r\n"},"comment":{"url":"https://api.github.com/repos/IdentityModel/IdentityModel/issues/comments/259151469","html_url":"https://github.com/IdentityModel/IdentityModel/issues/60#issuecomment-259151469","issue_url":"https://api.github.com/repos/IdentityModel/IdentityModel/issues/60","id":259151469,"user":{"login":"leastprivilege","id":1454075,"avatar_url":"https://avatars.githubusercontent.com/u/1454075?v=3","gravatar_id":"","url":"https://api.github.com/users/leastprivilege","html_url":"https://github.com/leastprivilege","followers_url":"https://api.github.com/users/leastprivilege/followers","following_url":"https://api.github.com/users/leastprivilege/following{/other_user}","gists_url":"https://api.github.com/users/leastprivilege/gists{/gist_id}","starred_url":"https://api.github.com/users/leastprivilege/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leastprivilege/subscriptions","organizations_url":"https://api.github.com/users/leastprivilege/orgs","repos_url":"https://api.github.com/users/leastprivilege/repos","events_url":"https://api.github.com/users/leastprivilege/events{/privacy}","received_events_url":"https://api.github.com/users/leastprivilege/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T14:32:54Z","updated_at":"2016-11-08T14:32:54Z","body":"OK - fixed. give it a try."}}
{"actor":{"display_login":"leastprivilege"}}