concept default in category security
appears as: defaults, default, defaults, The default, default

This is an excerpt from Manning's book API Security in Action.
Produce correct Content-Typeheaders on all your API’s responses, and never assume the defaults are sensible. Check error responses in particular, as these are often configured to produce HTML by default.
Figure 4.2 An error message in the JavaScript console when loading the HTML page directly. The request was blocked because the local file is considered to be on a separate origin to the API and so browsers will block the request by default.
![]()
Listing 13.18 The full device authorization grant flow
public static void main(String... args) throws Exception { var clientId = "deviceGrantTest"; var scope = "a b c"; var json = beginDeviceAuthorization(clientId, scope); #A var deviceCode = json.getString("device_code"); #A var interval = json.optInt("interval", 5); #A System.out.println("Please open " + #B json.getString("verification_uri")); #B System.out.println("And enter code:\n\t" + #B json.getString("user_code")); #B while (true) { #C Thread.sleep(TimeUnit.SECONDS.toMillis(interval)); #C json = pollAccessTokenEndpoint(clientId, deviceCode); #C var error = json.optString("error", null); if (error != null) { switch (error) { case "slow_down": #D System.out.println("Slowing down"); #D interval += 5; #D break; case "authorization_pending": #E System.out.println("Still waiting!"); #E break; default: System.err.println("Authorization failed: " + error); System.exit(1); break; } } else { System.out.println("Access token: " + #F json.getString("access_token")); #F break; } } }