<commit_before># Using Auth0 in PHP APIs

@@includes.apinote@@

Install the following package from composer

    firebase/php-jwt

On your protected APIs, add a check like the following:

    // validate the token
    $token = str_replace($_SERVER['Authorization'], 'Bearer ', '')
    $secret = "@@account.clientSecret@@"
    $decoded_token = JWT::decode($token, base64_decode(strtr($secret, '-_', '+/')) );

    // validate that this token was made for us
    if ($decoded_token->aud == "@@account.clientId@@") {
      header('HTTP/1.0 401 Unauthorized');
    }

@@includes.callapi@@
<commit_msg>Update phpapi-tutorial.md<commit_after># Using Auth0 in PHP APIs

@@includes.apinote@@

Install the following package from composer

    firebase/php-jwt

On your protected APIs, add a check like the following:

    // validate the token
    $token = str_replace('Bearer ', '', $_SERVER['Authorization'])
    $secret = "@@account.clientSecret@@"
    $decoded_token = JWT::decode($token, base64_decode(strtr($secret, '-_', '+/')) );

    // validate that this token was made for us
    if ($decoded_token->aud == "@@account.clientId@@") {
      header('HTTP/1.0 401 Unauthorized');
    }

@@includes.callapi@@

{'fraction_non_alphanumeric': 0.15422885572139303, 'fraction_numerical': 0.013266998341625208, 'mean_word_length': 3.828, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4966870', 'n_tokens_mistral': 392, 'n_tokens_neox': 369, 'n_words': 101}