PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label two-factor-authentication. Show all posts
Showing posts with label two-factor-authentication. Show all posts

Saturday, November 19, 2022

[FIXED] How do I send a user token via SMS with Authy and PHP?

 November 19, 2022     authy, php, twilio, twilio-php, two-factor-authentication     No comments   

Issue

I am trying to run a demo for Authy in PHP. I have installed the Authy library with Composer, so now I can register a user using hardcoded values like this:

$authy_api = new Authy\AuthyApi('<TESTING API KEY>', 'http://sandbox-api.authy.com'); // actual key omitted -- using the key generated for testing, not the one for production

$user = $authy_api->registerUser('something@something.com', '999-999-9999', 30); // actual credentials omitted

if($user->ok()){
    echo "Success!";
    $id = $user->id();
    echo($id);  
}

When the above script runs, a 5-digit user id is indeed generated, so all seems to be going well, yet the SMS is never delivered to my phone.

One possible problem could be that my number is already registered as the app phone (associated with the admin account), so since (per the docs) each phone number has to uniquely identify a user, maybe mine was already registered for this app and therefore no need arose to send a new token. Should that be the case, the id of the user object may be the previously registered one.

The problem remains with other phone numbers however. So now I'm lost.


Solution

Turns out, there was nothing wrong with the code per se.

It's just the Sandbox API does not actually go through with sending the SMS. It only simulates the process for testing purposes, so that the authentication flow is the same as with the production API.

When I switched to production API URL and key, I was able to receive the SMS on my phone.



Answered By - Guybrush Threepwood
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, July 12, 2022

[FIXED] How to populate OTP from user's message box to application directly in iPhone?

 July 12, 2022     ios, iphone, message, one-time-password, two-factor-authentication     No comments   

Issue

I am working on an internet trading application with its mobile and iPhone applications available. With the recent market trend, we are working on including two-factor authentication. For that, we will be sending a one-time password as a sms on user's registered mobile number.

Is there a way,that the OTP can get automatically populated into application from user's message box in iPhone? What algorithm should I use to make my app read user's message box?

Thanks in advance:)


Solution

You can Access SMS from your app. So better make user to enter his contact number and send SMS to his mobile

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if (!url) {
        UIApplication * yourapplication =[UIApplication sharedApplication];
        NSString *outputpath =@"appname://data/";
        NSURL *url =[NSURL URLWithString:outputpath];
        [yourapplication openURL:url];
        return NO;
    }

    NSUserDefaults *defaultString =[NSUserDefaults standardUserDefaults];
    NSString * commonString =[url absoluteString];
    if (commonString.length<=15) {
        //
    }
    else
    {
        [defaultString setObject:commonString forKey:@"urlString"];
    }
         //send info to the screen you need and can navigate
    return YES;
}


Answered By - Charan Giri
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing