Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication Error - No credentials provided #275

Closed
mohammedabualsoud opened this issue Jan 2, 2016 · 1 comment
Closed

Authentication Error - No credentials provided #275

mohammedabualsoud opened this issue Jan 2, 2016 · 1 comment

Comments

@mohammedabualsoud
Copy link

mohammedabualsoud commented Jan 2, 2016

I'm struggling with sending a msg from your twilio api, I tested your demos that exists on the twilio website on my local server with the following features:
host : (i686-pc-linux-gnu)
libcurl php version: 7.35.0
ssl version: OpenSSL/1.0.1f.

It works my local server but on this server with the following features :
host : x86_64-redhat-linux-gnu
libcurl php version : 7.19.7
ssl version: NSS/3.19.1 Basic ECC
it didn't work.
Here's the output of the curl request to the twilio api:

{"code": 20003, "detail": "Your AccountSid or AuthToken was incorrect.", "message": "Authentication Error - No credentials provided", "more_info": "https://www.twilio.com/docs/errors/20003", "status": 401}1

the code:

<?php
//my trial account sid, and token
$sid = "XXXXXXXXXXXXX"; // Your Account SID from www.twilio.com/user/account
$token = "XXXXXXXXXXXX"; // Your Auth Token from www.twilio.com/user/account

function send_sms( $sid, $token, $to, $from, $body ) {
    // resource url & authentication
    $uri = 'https://api.twilio.com/2010-04-01/Accounts/' . $sid . '/SMS/Messages.json';
    $auth = $sid . ':' . $token;

    // post string (phone number format= +15554443333 ), case matters
    $fields = 
        '&To=' .  urlencode( $to ) . 
        '&From=' . urlencode( $from ) . 
        '&Body=' . urlencode( $body );

    // start cURL
    $res = curl_init($uri);

    // set cURL options
    curl_setopt( $res, CURLOPT_POST, TRUE ); 
    curl_setopt( $res, CURLOPT_RETURNTRANSFER, TRUE ); // don't echo
    curl_setopt( $res, CURLOPT_SSL_VERIFYPEER, FALSE );
    curl_setopt( $res, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
    curl_setopt( $res, CURLOPT_USERPWD, $auth ); // authenticate
    curl_setopt( $res, CURLOPT_POSTFIELDS, $fields );


    // send cURL
    $result = curl_exec( $res );
    curl_close($res);
    return $result;
}
echo send_sms($sid,$token,"+XXXXXXX","+XXXXXXXXXXX","TESTING");
?>

I hope you know what is the problem but I think it's related to the ssl version, that included with the php curl extention on the server.

PS: I have no access to the second server so that I cannot upgrade the libcurl extention to the latest version, which I think the reason of the problem.

@ihumanable
Copy link
Contributor

I would suggest using the twilio-php helper library instead of rolling your own on raw curl_* commands. This forum is for help with the twilio-php helper library not general purpose help, for general support please contact help@twilio.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants