NSURLConnection Authorization Header not Working

后端 未结 4 1770
别那么骄傲
别那么骄傲 2021-02-01 06:16

I am trying to send an OAuth access token in an HTTP header via NSURLConnection but it doesn\'t seem to be sending the header because the API keeps giving me an error saying tha

4条回答
  •  逝去的感伤
    2021-02-01 06:38

    Change this line:

    NSURL *aUrl = [NSURL URLWithString: @"http://generericfakeapi.com/user/profile"];
    

    To:

    NSURL *aUrl = [NSURL URLWithString: @"http://generericfakeapi.com/user/profile/"];
    

    Apparently iOS drops the Authorization header if there isn't a slash at the end of a URL. This problem literally cost me my sleep for two days.

提交回复
热议问题