{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3918","repository_url":"https://api.github.com/repos/xamarin/Xamarin.Forms","labels_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3918/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3918/comments","events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3918/events","html_url":"https://github.com/xamarin/Xamarin.Forms/issues/3918","id":364444947,"node_id":"MDU6SXNzdWUzNjQ0NDQ5NDc=","number":3918,"title":"HttpClient not accepting Authorization headers (401 Unauthorized)","user":{"login":"dush88c","id":9262431,"node_id":"MDQ6VXNlcjkyNjI0MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/9262431?v=4","gravatar_id":"","url":"https://api.github.com/users/dush88c","html_url":"https://github.com/dush88c","followers_url":"https://api.github.com/users/dush88c/followers","following_url":"https://api.github.com/users/dush88c/following{/other_user}","gists_url":"https://api.github.com/users/dush88c/gists{/gist_id}","starred_url":"https://api.github.com/users/dush88c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dush88c/subscriptions","organizations_url":"https://api.github.com/users/dush88c/orgs","repos_url":"https://api.github.com/users/dush88c/repos","events_url":"https://api.github.com/users/dush88c/events{/privacy}","received_events_url":"https://api.github.com/users/dush88c/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-27T12:09:26Z","updated_at":"2018-09-27T17:57:19Z","closed_at":"2018-09-27T17:57:19Z","author_association":"NONE","body":"I have used **System.Net.Http** to create an HTTP client to access the Web API GET method which is authorized as below. But it returns **unauthorized** (401) error always even if it works fine in Postman with same authorization token (**Bearer**)\r\n\r\n\r\n```\r\nusing (var ProfileClient = new HttpClient())\r\n            {\r\n                var token = OAuthToken.Instance.AccessToken;\r\n                ProfileClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(\"Bearer\", token);\r\n                \r\n                var response = await ProfileClient.GetAsync(AppSettings.AbbottAuthorizationProfileUrl);\r\n                \r\n                if (response.StatusCode == System.Net.HttpStatusCode.OK)\r\n                {\r\n                    return CheckProfileReturn(response);\r\n                }\r\n                else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)\r\n                {\r\n                    return new Tuple<bool, string>(false, \"Unauthorized access\");\r\n                }\r\n                else\r\n                {\r\n                    var result = await response.Content.ReadAsStringAsync();\r\n                    var errorModel = JsonConvert.DeserializeObject<OauthError>(result);\r\n                    return new Tuple<bool, string>(false, errorModel?.ErrorDescription);\r\n                }\r\n            }\r\n```\r\n\r\nI have no idea why this is not working in Xamarin.Forms httpclient ?\r\nVersions \r\nXamarin Forms : 2.4.0.280\r\nSystem.Net.Http : MonoAndroid\\v1.0\\4.0.30319 \r\n![http](https://user-images.githubusercontent.com/9262431/46144938-1e024a80-c27c-11e8-8a17-1390cad4cf6f.JPG)\r\n.Net : 4.5\r\n\r\nThanks\r\n"},"comment":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/comments/425186257","html_url":"https://github.com/xamarin/Xamarin.Forms/issues/3918#issuecomment-425186257","issue_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/3918","id":425186257,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTE4NjI1Nw==","user":{"login":"rmarinho","id":1235097,"node_id":"MDQ6VXNlcjEyMzUwOTc=","avatar_url":"https://avatars3.githubusercontent.com/u/1235097?v=4","gravatar_id":"","url":"https://api.github.com/users/rmarinho","html_url":"https://github.com/rmarinho","followers_url":"https://api.github.com/users/rmarinho/followers","following_url":"https://api.github.com/users/rmarinho/following{/other_user}","gists_url":"https://api.github.com/users/rmarinho/gists{/gist_id}","starred_url":"https://api.github.com/users/rmarinho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmarinho/subscriptions","organizations_url":"https://api.github.com/users/rmarinho/orgs","repos_url":"https://api.github.com/users/rmarinho/repos","events_url":"https://api.github.com/users/rmarinho/events{/privacy}","received_events_url":"https://api.github.com/users/rmarinho/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T17:57:19Z","updated_at":"2018-09-27T17:57:19Z","author_association":"MEMBER","body":"Hi this doesn't seem a issue related with Xamarin.Forms itself.\r\n\r\nTrying to help you might want to migrate to use the latest version of Xamarin Forms like 3.2.0 that uses netstandard .\r\n\r\nYou should inspect the headers of the call to see how the request is form. also might want to check if its a https issue or something.\r\n\r\nFeel free to reopen if you figure is something wrong with Xamarin.Forms.\r\n\r\nThanks"}}
{"actor":{"display_login":"rmarinho"}}