xmlhttprequesthttp-headersrate-limitingresponse-headers

Where are the exposed headers informing my Rate Limit for the Geni API?


Anytime I use the Client Side Flow to authorize my Geni app with OAuth2, I can successfully get it to authenticate me but I receive the error:

{"error":{"type":"ApiException","message":"Rate limit exceeded."}}

(I am using the endpoint https://www.geni.com/api/user/metadata?ids="[my_id]")

According to the documentation, the rate limits can be checked within the HTTP headers. Geni's Rate Limits documentation However, when I check the Response Headers within Google Chrome's Network tab, all I see is:

==Response Headers==
Access-Control-Allow-Credentials: true

Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description, X-Requested-With, X-Prototype-Version, X-API-Rate-Limit, X-API-Rate-Remaining, X-API-Rate-Window

Access-Control-Allow-Methods: POST, GET, OPTIONS

Access-Control-Expose-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description, X-Requested-With, X-Prototype-Version, X-API-Rate-Limit, X-API-Rate-Remaining, X-API-Rate-Window

So things like X-API-Rate-Window are THERE, given permission to be exposed, but they're only values instead of the keys and there are no corresponding additional headers with those names used as the keys. Therefore, I can't figure out a way to extract any useful information from them.

Can someone advise me on how to read what my remaining Rate Limit is, and how I can access metadata information without tripping it?

Thanks!

(P.S. I've posted this question to Geni's forums and have received no response which is why I am posting it here :) )


Solution

  • I finally resolved this. I learned about preflight requests and how that was the request whose Response Headers I was looking at before.

    It turns out Geni was passing its custom headers to my main request, I just had a line of code in my own proxy PHP file that was omitting most headers.

      foreach ( $header_text as $header ) {
        if ( preg_match( '/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header ) ) {
          header( $header );
        }
      }
    

    (I was using this proxy, for reference.)

    When I removed that regex check from the proxy, all of the headers began appearing!