How to send jwt token algorithm in http header

×

Error message

  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Undefined index: value in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Undefined index: value in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type bool in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type null in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type bool in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type null in answers_field_get_value() (line 24 of H:\root\home\marcluo777-001\www\healthcentre\sites\all\modules\answers\includes\answers.field_utils.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of H:\root\home\marcluo777-001\www\healthcentre\includes\common.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of H:\root\home\marcluo777-001\www\healthcentre\includes\menu.inc).

Primary tabs

+1
+4
-1

I have a resource that generates a tokens for users. I want to add possibility choose token generation algorithm. I can't change request structure but can add some http header with algorithm name. My question is what header to choose? Is Accept would be acceptable?

now I use a Accept-Token-Algorithm header to send values like: RS256, HS256

If both client and server agree with Accept-Token-Algorithm

+1
+2
-1

There's no standard header for that purpose.

If both client and server agree with Accept-Token-Algorithm, that seems to be a reasonable choice. More descriptive (and verbose) alternatives would be Accept-Token-Signature-Algorithm (assuming the JWT is actually a JWS) and Accept-Token-Encryption-Algorithm (for JWE).

Keep in mind that your API is as good as the documentation you provide for it and custom headers are not obvious to API consumers. So ensure that you document it properly.

You also should consider falling back to a default algorithm if the desired header is not present in the request and ensure that you validate the values you receive. Refer to the RFC 7518 for a list of the valid algorithms for JWS and for valid algorithms for JWE.