https://github.com/lholden/authy-rs
Rust API bindings for the Authy services.
https://github.com/lholden/authy-rs
2fa authentication authy two-factor
Last synced: 5 months ago
JSON representation
Rust API bindings for the Authy services.
- Host: GitHub
- URL: https://github.com/lholden/authy-rs
- Owner: lholden
- License: other
- Created: 2017-03-18T07:54:05.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-26T15:16:42.000Z (about 7 years ago)
- Last Synced: 2025-07-01T11:51:34.129Z (7 months ago)
- Topics: 2fa, authentication, authy, two-factor
- Language: Rust
- Size: 52.7 KB
- Stars: 9
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Authy-rs
[](https://docs.rs/authy) [](https://crates.io/crates/authy) [](https://travis-ci.org/lholden/authy-rs)
Bindings for the Authy two factor web service
## Usage
Please see the [Documentation](https://docs.rs/authy) for more details.
You will need your API key for your application on [authy.com](https://authy.com).
Be sure to add the authy crate to your `Cargo.toml`:
```toml
[dependencies]
authy = "*"
```
'low-level' Usage example:
```rust
extern crate authy;
use authy::{Client, AuthyError};
use authy::api::user;
fn main() {
let api_url = "https://sandbox-api.authy.com";
let api_key = "bf12974d70818a08199d17d5e2bae630";
let c = Client::new(api_url, api_key);
let country_code = 1;
let email = "user@domain.com";
let phone = "949-555-1234";
let (_, user) = user::create(&c, email, country_code, phone, true).unwrap();
println!("We have a user: {:#?}", user);
let code = "000000"; // Pretend user has provided a valid code
match user::verify(&c, user.id, code) {
Ok(_) => println!("Congrats on being validated!"),
Err(AuthyError::UnauthorizedKey(e)) => println!("Token provided by the user was wrong"),
Err(e) => println!("Some server error: {:?}", e),
};
// Lets send out a sms token just for fun
// Must be using a real API key on the production authy server for this to
// actually send out anything.
user::sms(&c, user.id, true, Some("login"), Some("Authy documentation example login")).unwrap();
}
```
'high-level' Usage example:
```rust
extern crate authy;
use authy::{Client, User};
fn main() {
let api_url = "https://sandbox-api.authy.com";
let api_key = "bf12974d70818a08199d17d5e2bae630";
let c = Client::new(api_url, api_key);
let country_code = 1;
let email = "user@domain.com";
let phone = "949-555-1234";
let mut user = User::create(&c, email, country_code, phone, true).unwrap();
println!("We have a user: {:#?}", user);
let code = "000000"; // Pretend user has provided a valid code
if user.verify(&c, code).unwrap() {
println!("Congrats on being validated!");
}
// Lets send out a sms token just for fun
// Must be using a real API key on the production authy server for this to
// actually send out anything.
user.sms(&c, true, Some("login"), Some("Authy documentation example login")).unwrap();
}
```
## License
Authy-rs is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)
## Contributing
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.
Please see the [CONTRIBUTING](CONTRIBUTING.md) file for more information.