Giter VIP home page Giter VIP logo

authy-php's Introduction

Packagist version Build Status

🚨🚨🚨

This library is no longer actively maintained. The Authy API has been replaced with the Twilio Verify API. Twilio will support the Authy API through November 1, 2022 for SMS/Voice. After this date, we’ll start to deprecate the service for SMS/Voice. Any requests sent to the API after May 1, 2023, will automatically receive an error. Push and TOTP will continue to be supported through July 2023.

Learn more about migrating from Authy to Verify.

Please visit the Twilio Docs for:

Please direct any questions to Twilio Support. Thank you!

🚨🚨🚨

PHP Client for Twilio Authy Two-Factor Authentication (2FA) API

Documentation for PHP usage of the Authy API lives in the official Twilio documentation.

The Authy API supports multiple channels of 2FA:

  • One-time passwords via SMS and voice.
  • Soft token (TOTP via the Authy App)
  • Push authentication via the Authy App

If you only need SMS and Voice support for one-time passwords, we recommend using the Twilio Verify API instead. More on how to choose between Authy and Verify here.

Authy Quickstart

For a full tutorial, check out the PHP/Laravel Authy Quickstarts in our docs:

Authy PHP Installation

This library requires PHP 5.6+

Install with composer. The authy/php package is available on Packagist.

Include in your composer.json as follows:

{
    "require": {
        "authy/php": "3.0.5"
    }
}

Usage

To use the Authy client, import AuthyApiClient and initialize it with your production API Key found in the Twilio Console:

$authy_api = new Authy\AuthyApi('#your_api_key');

authy api key in console

2FA Workflow

  1. Create a user
  2. Send a one-time password
  3. Verify a one-time password

OR

  1. Create a user
  2. Send a push authentication
  3. Check a push authentication status

Phone Verification

Phone verification now lives in the Twilio API and has PHP support through the official Twilio helper libraries.

Legacy (V1) documentation here. Verify V1 is not recommended for new development. Please consider using Verify V2.

Contributing

You can use docker to run tests and develop locally without the need to install the dependencies directly in your machine:

git clone [email protected]:authy/authy-php.git
cd authy-php
make docker-build # Creates the docker image
make docker-deps  # Install dependencies (in the `vendor` directory)
make docker-test  # Runs the tests

To contribute, make your changes in a branch and send a Pull Request to the twilio/authy-php repo.

Copyright

Copyright (c) 2011-2020 Authy Inc. See LICENSE for further details.

authy-php's People

Contributors

castis avatar chrisdeeming avatar cmodijk avatar dcu avatar enygma avatar giampy5 avatar goodeath avatar luisuribe avatar merlin-bud avatar robinske avatar rotorsolutions avatar senekis avatar serargz avatar tufla avatar vargasx avatar zqueal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

authy-php's Issues

PHP 5.4 required? (Guzzle dependency)

Loading composer repositories with package information

Installing dependencies (including require-dev)

Your requirements could not be resolved to an installable set of packages.

Problem 1

  • guzzlehttp/guzzle 5.3.0 requires php >=5.4.0 -> your PHP version (5.3.27) does not satisfy that requirement.

Is there any workaround?

GitHub Changes doesn't reflect on packagist

Hi Authors
i recently installed this library via composer, i am unable to see the updated version that is on git hub for e.g whole phone verification methods are missing.

your urgent action required..

QR Code method missing from 4.x release

Somehow the qrCode method was merged directly into a 3.x release branch, and is missing from the 4.x release due to it not being available in master.

The PR in question: #61

Guzzle Version

Hello there,
Can you please upgrade the guzzle to latest version ? Mostly other packages require guzzle version to 6.0.0 or above but authy require 5.3.1 or lower.

Thank you.

how to obtain authy-id after creating a user

Hi,

After I create a user using the API, e.g.:
$user = $authy_api->registerUser('email', 'xxx-xxx-xxxx', '1');

How could I get the 'authy-id' from the return $user object?

The command print_r($user) shows that it is a 'protected' field so I guess there is a function like 'getID' or something to retrieve the 'authy-id'?

Authy\AuthyUser Object
(
[raw_response:protected] => GuzzleHttp\Psr7\Response Object
(
+-- 78 lines-------------------------------------------------------
)

[body:protected] => stdClass Object
    (
        [id] => 15xxxxxx0
    )

[errors:protected] => stdClass Object
    (
    )

)

Please advise. Thanks. Best regards,

Is this dead?

Hi,
is this library dead?
I'm actually using it and it would be bad if it won't be actively supported...

Project states PHP 5.3 compatibility but is rife with PHP 5.4 features

the version 2.5 README and composer.json both state 5.3.0 or greater.

however there are short array declarations [] in authy and the version of guzzle it depends on (and still further dependencies PSR, promises), there are callable type hints, static anonymous functions, anonymous functions with closure over $this, use of curl_reset in there, and probably other things i have not found yet as i revise the code to work with PHP 5.3.10.

there does not appear to be documentation anywhere noting which specific version of authy to use for PHP prior to 5.4 so now i am stuck trial-and-erroring my way backward through releases.

error 500 in WordPress

Hi!

I am trying to require Authy in my WordPress instalation, in my functions.php file but I am not able to create a new instance of Authy. The server responds with a error 500. Somebody knows if I have to do something else? Maybe I need to call to another dependency?

thanks

Class 'Resty' not found

Hey,

I just added authy to my composer.json in my new Laravel framework based project.

I did composer update (as I'd already installed Laravel completely before and just needed to add the Authy PHP SDK) and it downloaded Authy into my project ready to start using.

Trouble is, when I start using the API I get an error:

Class 'Resty' not found

Which points to the Authy code.

How can I fix this?

Guzzle http

Hi, can i use the v6 of Guzzle http with authy php ?

Thanks for reply

Guzzle 6 Support?

Our main app uses Guzzle 6, which afaik is the "current" version. Are there any plans to update this package to use Guzzle 6?

Upgrade to Guzzle 7.x

Laravel 8 just got released and ships with Guzzle version 7.x out of the box. For now, the package can't be used in a new Laravel 8 project as the current stable release (3.0.5) requires Guzzle v6.0.x and the RC (3.1.0) requires v6.5.x.
Installing it produces the error below:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for guzzlehttp/guzzle (locked at 7.0.1, required as ^7.0.1) -> satisfiable by guzzlehttp/guzzle[7.0.1].
    - authy/php 3.0.4 requires guzzlehttp/guzzle ~6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - authy/php 3.0.5 requires guzzlehttp/guzzle ~6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - authy/php 3.1.0-rc1 requires guzzlehttp/guzzle ~6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - authy/php v3.0 requires guzzlehttp/guzzle ~6.0 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
    - Conclusion: don't install guzzlehttp/guzzle 6.5.x-dev
    - Installation request for authy/php ^3.0 -> satisfiable by authy/php[3.0.4, 3.0.5, 3.1.0-rc1, v3.0]

Guzzle 6.0 incompatibility

It would be nice to release a version of Authy-PHP using Guzzle 6.0 instead of Guzzle 5.0. Actually I can't use this library in the project where I'm working because there is a dependencies conflict.

Composer tries to install a very old version of Authy-PHP because it uses Resty instead of Guzzle, but it lacks a lot of features, so that is not a solution for me.

If "semver" is used for Authy-PHP versioning, then it should be easy to port the current version to Guzzle 6.0 without having to worry about breaking backwards compatibility.

Please make new releases

The last official release was version 3.0 in January, but since then there have been a number of potentially significant updates. Most of them have bumped the version, which in retrospect may not have been necessary.

I currently have my project pulling directly from dev-master but that's a fairly poor practice and makes me slightly nervous as it means my project will automatically receive the newer code, even if there are BC issues.

I'm not sure whether you want to bump the version back down to 3.0.1 and do a release or even bump it forward to 3.1 (#55 could represent breaking changes for extending code as assumptions about the base_uri may now be invalidated in order to have made OneTouch work).

Either way, some official release would be ideal 👍

One touch verification endpoints

Hi Guys,

I started using Authy for our project and I think that you made nice stuff but there is one issue with your library. I want to use one touch verification feature and had to extend your API class to handle this. Is there possible to merge pull request regarding one touch verification in the next release? Will be nice ;)

Best regards :)

Conflict in dependancies with spring boot 2.0.5

For anyone using spring boot 2.0.5, I was getting the following error during runtime
java.lang.NoSuchMethodError: org.json.JSONObject

to resolve I needed to exclude the following com.vaadin.external.google from spring-boot-starter-test:

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		   	<exclusions>
		   		<exclusion> 
		          	<groupId>com.vaadin.external.google</groupId>
		          	<artifactId>android-json</artifactId>
		       </exclusion>
     			</exclusions> 
		</dependency>

As that package had its own org.json dependency. Hope this saves someone some time

Cannot auth using example

Trying to auth with PHP library as per example without success

Auth attempts return stream error with url http://verify/{tokencode}/token{key}?force=true

it looks like the api url isnt loading correctly

In the code it is stated as

 $resp = $this->rest->get("verify/{$token}/{$authy_id}", array(

            'query' => $params
        ));

It doesnt appear to be loading the $api_url which is listed in AuthyApi.php as https://api.authy.com

If I try and manually run this I get notification that this is the wrong url being api.authy.com/verify is incorrect.

I have checked the python library and it uses api.authy.com/protected/json/verify can you advise what the correct url is?

If I attempt to use this url I get "error_code":"60001","message":"Invalid API key","errors":{"message":"Invalid API key"},"success":false

VerifyToken

So using the method verifyToken is giving me some problems. When I analyze the response I get this:

object(Authy\AuthyResponse)#582 (3) {
  ["raw_response":protected]=>
  array(6) {
    ["meta"]=>
    NULL
    ["body"]=>
    NULL
    ["error"]=>
    bool(true)
    ["error_msg"]=>
    string(359) "Stream open failed for '/protected/json/verify/4095167/6317476?api_key=my_key&force=true'; req_time: 4.792213439941406E-5; opts: {"http":{"timeout":240,"method":"GET","content":null,"user_agent":"authy-php v1.3.0","header":["Content-Type: application\/x-www-form-urlencoded","Connection: close"],"ignore_errors":1,"max_redirects":0}}"
    ["status"]=>
    int(0)
    ["headers"]=>
    array(0) {
    }
  }
  ["body":protected]=>
  NULL
  ["errors":protected]=>
  object(stdClass)#589 (0) {
  }
}

But when I do the GET call manually with postman:
captura de pantalla de 2015-04-27 09 02 38
it works perfectly

{
"message": "Token is valid.",
"token": "is valid",
"success": "true"
}

Support errors and status codes as stated on Twilio API

Currently due to the implementation of the AuthyResponse class (protected internal variables), there is no way to access the response body or status code directly without rewriting (extending classes) of the library yourself.

This creates an issue with error handling. As stated here https://www.twilio.com/docs/verify/return-and-error-codes there are multiple status codes as well as custom error codes (which are part of the response's body).

It would be beneficial to add a body() and a statusCode() function (or similar) to the said class.

public function body()
{
        return $this->body;
}

public function statusCode()
{
        return $this->raw_response->getStatusCode();
}

It appears that there is a bodyvar method. However, the status code is not available and bodyvar is restricting the usage of custom exception handling based on the body contents, you need to retrieve every variable independently.

Help with Error_code when I create an user

Hi,
I need help with my code, I can't create an user; always I have the error_code 60030 and I dont find the error on the code.
If someone finds it, I would appreciate it too much. It's for a college project for my grades.
Thanks.

`<?php
$tituloPagina = "Activacion 2FA";
session_start();

include_once "registro.php";
include_once "conexion.php";
require "vendor/autoload.php"; //accedemos a las librerias del composer.json


$apiKey = "WeuGMlbzYPfa9uz0ZZ50BZd16H9nDsiv";
$apiUrl= "https://api.authy.com/protected/json/users/new?api_key=WeuGMlbzYPfa9uz0ZZ50BZd16H9nDsiv";

?>

Activacion del segundo factor de autenticación

Email: *
País: *
Celular: *
<script src="jsform.authy.js"></script>

Recuerde descargar la App de Authy

registerUser($email, $celular, $codPais); if ($user->ok()) { echo '<script language="javascript">alert("'.$user->id().'");</script>'; echo '<script language="javascript">alert("El Id authy para el usuario "'.$email.'" es: '.$user->id().'");</script>'; $id_authy=$user->id(); $insertar=mysqli_query($conexion,"INSERT INTO usuarios(celular,pais,id_authy) VALUES ('$codPais','$celular','$id_authy') WHERE email='".$email."'") or die (mysqli_error($conexion)); echo '<script language="javascript">alert("Activacion Exitosa");</script>'; echo "<script language='javascript'>window.location='productos.php'</script>"; }else{ foreach ($user->errors() as $field => $error) { echo 'Error en '.$field.': '.$error; } } } include ("inc/footer.php"); ?>`

Unable to Change Locale. (SMS Language)

  1. On Twilio, Default locale is Identified on basis of Country code, But on Authy its documented as "en" (English)

  2. There is no way to overide default locale. For Ex, I want to set language as "English" default was "Hindi", as per Twilio, i need to pass locale = 'en' in request params , but in
    Authy->phoneVerificationStart there is no way to pass that param, i need to manually edit this function to add this param, to got it working.

Please add Twilio supported Params,
https://www.twilio.com/docs/verify/api/verification#request-a-verification-code

Update the docs

Could you please do the world a favor and update the readme to correspond to the code, so we don't waste our time implmenting a workflow that's no longer valid...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.