{"action":"created","issue":{"url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios/issues/234","repository_url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios","labels_url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios/issues/234/comments","events_url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios/issues/234/events","html_url":"https://github.com/zendesk/zendesk_sdk_ios/issues/234","id":179610040,"number":234,"title":"'Failed to fetch attachments' with 401 auth error","user":{"login":"asutula","id":528969,"avatar_url":"https://avatars.githubusercontent.com/u/528969?v=3","gravatar_id":"","url":"https://api.github.com/users/asutula","html_url":"https://github.com/asutula","followers_url":"https://api.github.com/users/asutula/followers","following_url":"https://api.github.com/users/asutula/following{/other_user}","gists_url":"https://api.github.com/users/asutula/gists{/gist_id}","starred_url":"https://api.github.com/users/asutula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asutula/subscriptions","organizations_url":"https://api.github.com/users/asutula/orgs","repos_url":"https://api.github.com/users/asutula/repos","events_url":"https://api.github.com/users/asutula/events{/privacy}","received_events_url":"https://api.github.com/users/asutula/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-09-27T20:50:47Z","updated_at":"2016-09-27T21:36:41Z","closed_at":null,"body":"- SDK version: 1.7.4.1\r\n- Xcode version: 7.3.1\r\n- iOS or Simulator: Both\r\n- iOS Version: 9 and 10\r\n- Swift version: 2.2\r\n\r\nSteps to Reproduce:\r\n\r\n1. Configure iOS Zendesk SDK with keys that point at a production Zendesk environment that is managed on the back end as a 'brand' (it uses a different sub-domain). This Zendesk account also supports multiple languages.\r\n2. In the iOS app, present the Zendesk view controller to display a list of help articles.\r\n3. Select an article.\r\n4. The text of the article is displayed, but see error message 'Failed to fetch attachments' appear at the top of the article.\r\n\r\nLooking at the network requests, I can see a possible problem:\r\n\r\nThe request for attachments is made (notice the presence of the Authorization header):\r\n```\r\nGET /api/v2/help_center/articles/219119268/attachments/block.json&per_page=1000 HTTP/1.1\r\nHost: mobile-apps.zendesk.com\r\nClient-Identifier: mobile_sdk_client_<snip!>\r\nContent-Type: application/json\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nAccept: application/json\r\nUser-Agent: Zendesk-SDK/1.6.1.1 iOS/9.3 Env/Development\r\nAuthorization: Bearer <bearer token is present>\r\nMobile-Sdk-Identity: <snip!>\r\nAccept-Language: en-us\r\n```\r\nWith the 302 redirect response:\r\n```\r\nHTTP/1.1 302 Found\r\nServer: nginx\r\nDate: Tue, 27 Sep 2016 18:59:08 GMT\r\nContent-Type: text/html; charset=utf-8\r\nStatus: 302 Found\r\nX-UA-Compatible: IE=edge\r\nX-XSS-Protection: 1; mode=block\r\nX-Frame-Options: SAMEORIGIN\r\nX-Zendesk-API-Version: v2\r\nLocation: https://mobile-apps.zendesk.com/api/v2/help_center/en-us/articles/219119268/attachments/block.json&per_page=1000?\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\nAccess-Control-Expose-Headers: X-Zendesk-API-Warn\r\nX-Zendesk-User-Id: \r\nStrict-Transport-Security: max-age=86400;\r\nX-Zendesk-Origin-Server: hcapp3.pod9.iad1.zdsys.com\r\nX-Request-Id: <snip!>\r\nX-Runtime: 0.056023\r\nCache-Control: must-revalidate, private, max-age=0\r\nX-Content-Type-Options: no sniff\r\nTransfer-Encoding: chunked\r\nConnection: Keep-alive\r\n\r\n<html><body>You are being <a href=\"https://mobile-apps.zendesk.com/api/v2/help_center/en-us/articles/219119268/attachments/block.json&amp;per_page=1000?\">redirected</a>.</body></html>\r\n```\r\nThe next request, to the redirect URL is made (note the absence of the Authorization header):\r\n```\r\nGET /api/v2/help_center/en-us/articles/219119268/attachments/block.json&per_page=1000? HTTP/1.1\r\nHost: mobile-apps.zendesk.com\r\nClient-Identifier: mobile_sdk_client_<snip>\r\nContent-Type: application/json\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nAccept: application/json\r\nUser-Agent: Zendesk-SDK/1.6.1.1 iOS/9.3 Env/Development\r\nMobile-Sdk-Identity: <snip!>\r\nAccept-Language: en-us\r\n```\r\nWith a 401 response:\r\n```\r\nHTTP/1.1 401 Unauthorized\r\nServer: nginx\r\nDate: Tue, 27 Sep 2016 18:59:09 GMT\r\nContent-Type: application/json; charset=utf-8\r\nStatus: 401 Unauthorized\r\nWWW-Authenticate: Zendesk realm=\"API\"\r\nX-Zendesk-User-Id: \r\nStrict-Transport-Security: max-age=86400;\r\nX-Zendesk-Origin-Server: hcapp1.pod9.iad1.zdsys.com\r\nX-Request-Id: <snip!>\r\nX-Runtime: 0.057289\r\nTransfer-Encoding: chunked\r\nConnection: Keep-alive\r\n\r\n{\"error\":\"Couldn't authenticate you\"}\r\n```\r\n\r\nSo it seems that the Authorization header getting dropped during the redirect could be the problem. I compared this to the series of requests/responses made from our equivalent Android app, and the Authorization header is maintained.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios/issues/comments/250006445","html_url":"https://github.com/zendesk/zendesk_sdk_ios/issues/234#issuecomment-250006445","issue_url":"https://api.github.com/repos/zendesk/zendesk_sdk_ios/issues/234","id":250006445,"user":{"login":"asutula","id":528969,"avatar_url":"https://avatars.githubusercontent.com/u/528969?v=3","gravatar_id":"","url":"https://api.github.com/users/asutula","html_url":"https://github.com/asutula","followers_url":"https://api.github.com/users/asutula/followers","following_url":"https://api.github.com/users/asutula/following{/other_user}","gists_url":"https://api.github.com/users/asutula/gists{/gist_id}","starred_url":"https://api.github.com/users/asutula/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asutula/subscriptions","organizations_url":"https://api.github.com/users/asutula/orgs","repos_url":"https://api.github.com/users/asutula/repos","events_url":"https://api.github.com/users/asutula/events{/privacy}","received_events_url":"https://api.github.com/users/asutula/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T21:36:41Z","updated_at":"2016-09-27T21:36:41Z","body":"To clarify, our primary Zendesk is host-mapped (support.example.com), but not this specific brand."}}
{"actor":{"display_login":"asutula"}}