JWT Auth not working after updates

  • dearvoodoo.yt
    Participant
    # 4 months ago

    After wordpress update to 6.0 and the plugin WordPress REST API Authentication to 2.3.0 the JWT token is not working anymore.
    Always returning me

    {
        "code": "rest_not_logged_in",
        "message": "Vous n’êtes actuellement pas connecté.",
        "data": {
            "status": 401
        }
    }

    Even if I generate a new token.

    dhruv
    Participant
    # 4 months ago

    Hi @dearvoodoo-yt,

    Could you please share the sample API request you are making?

    It would help us to point you in the right direction.

    Thanks
    Dhruv Bhavsar

    dearvoodoo.yt
    Participant
    # 4 months ago

    Hey !

    So I’m getting the token with this in PHP

    
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
        CURLOPT_URL => 'http://api.mydomain.com/wp-json/api/v1/token',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('username' => $username,'password' => $password),
    ));
    
    $response = json_decode(curl_exec($curl), false);
    
    curl_close($curl);
    

    And trying to get users with this (with jQuery)

    
    var token = Cookies.get('jwt_token')
    var settings = {
        "url": "https://api.mydomain.com/wp-json/wp/v2/users/me",
        "method": "GET",
        "timeout": 0,
        "headers": {
            "Authorization": 'Bearer ${token}'
        },
    };
    
    $.ajax(settings).done(function(data) {
        // do my things here :)
    });
    

    Not event working with Postman.
    But, weirdly working perfectly today just before updating.

    dhruv
    Participant
    # 4 months ago

    Hi @dearvoodoo-yt,

    The code looks good to me. Could you please raise the query from the plugin support form?
    We can have a screen share meeting to debug the issue for you.

    Thanks
    Dhruv Bhavsar

    dearvoodoo.yt
    Participant
    # 4 months ago

    Ok I found the problem.
    For unknown reason, some options have changed in “Protected REST API Settings”.
    The “/wp/v2/users/me” option was no longer checked.
    Thanks anyway for your time.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.