0 Replies
      Latest reply on Jan 15, 2019 6:42 AM by trahman
      trahman Level 1 Level 1 (0 points)

        Hello.

         

        I am trying to get a list of section id under my channel. I am following the Apple News API documentation (https://developer.apple.com/documentation/apple_news/list_all_sections) . But I am getting 401-unauthorized error? I am calculating the signature the same way as I do for article creation. Following is my code:

         

        String method = String.valueOf(HttpMethod.GET);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(method.getBytes(MESS_ENCODING));
        outputStream.write(url.getBytes(MESS_ENCODING));
        outputStream.write(appleDate.getBytes(MESS_ENCODING));
        
        
        byte[] base64EncodedMac = Base64.getEncoder().encode(hmacUtils.hmac(outputStream.toByteArray()));
        String signature = new String(base64EncodedMac);
        String authorization = String.format(HEADER_FORMAT, api_key_id, signature, appleDate);
        
        exchange.getOut().setHeader(AUTH_HEADER, authorization);
        exchange.getOut().setHeader(Exchange.HTTP_METHOD, method);
        
        

        Is there any other way to get section ID?

         

        Tahseen