OAuthResponseJSON
Overview
The OAuthResponseJSON
object is designed for handling JSON responses during OAuth authentication. It provides methods to extract key elements from the response, such as the body content, HTTP response code, and headers. Additionally, it allows parsing the response body into a JSON object for easier manipulation.
The getAsJSON()
method converts the response body into a JSON object, enabling structured data handling. For accessing raw content, the getBody()
method returns the response body as a string. The getCode()
method retrieves the HTTP response code as a number, which is useful for determining the status of the OAuth transaction. To access specific metadata, the getHeader(name)
method fetches the value of a header by name, while the getHeaders()
method returns all headers in an array format.
For more information about authentication using the OAuth service, refer to the OAuth Provider from the Authentication section of this documentation.
Methods Summarized
Methods Detailed
getAsJSON()
Returns: Object A JSON object representation of the response body. If the response body is a JSON array, it is wrapped in an object with the key "array". Returns null if the response body is empty or cannot be parsed as JSON.
getBody()
Returns: String The response body as a string, or null if an error occurs while reading it.
getCode()
Returns: Number The HTTP status code of the OAuth response.
getHeader(name)
Parameters
String name ;
Returns: String The value of the specified header, or null if the header is not present.
getHeaders()
Returns: Array An array of all header names in the OAuth response.
Last updated
Was this helpful?