• I’m trying to connect via basic auth using this script:

    <?php
    $username = "name";
    $password = "pass";
    
    $args = array(
        'headers' => array(
            'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password ),
        ),
    );
    echo '<pre>';
    echo http_get ( 'https://site.com/dev/wp/wp-json/users/me', $args );
    echo '</pre>';
    ?>

    The response I get is this:

    HTTP/1.1 401 Unauthorized
    Date: Mon, 25 May 2015 18:24:51 GMT
    Server: Apache/2.2.24 (Unix) mod_hive/5.0 mod_ssl/2.2.24 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_fcgid/2.3.6
    X-Powered-By: PHP/5.4.33
    X-Pingback: https://www.betypist.com/dev/wp/xmlrpc.php
    X-Content-Type-Options: nosniff
    Host-Header: 192fc2e7e50945beb8231a492d6a8024
    Transfer-Encoding: chunked
    Content-Type: application/json; charset=UTF-8
    
    4c
    [{"code":"json_not_logged_in","message":"You are not currently logged in."}]
    0

    Any ideas on why?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘basic authentication’ is closed to new replies.