This document provides details on the mobile API endpoints for the myAuthenticator project. These endpoints are used for user authentication, registration, scanning QR codes, generating and verifying OTPs, and managing apps (including delete and update operations). Use this documentation to integrate and troubleshoot your mobile application.
Note: For local testing using an Android emulator, use http://10.0.2.2/ in place of localhost. For real devices, use your PC’s IP address (e.g., http://192.168.x.x/). In production, always use HTTPS.
Base URL: http://<server-address>/myauthenticator_api/mobile_api/
Example for emulator: http://10.0.2.2/myauthenticator_api/mobile_api/
URL: login.php
Method: POST
Headers: Content-Type: application/json
Request Body:
{
"email": "user@example.com",
"password": "user_password"
}
Successful Response:
{
"status": "success",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Error Response:
{
"status": "error",
"message": "Missing email or password"
}
URL: user_register.php
Method: POST
Headers: Content-Type: application/json
Request Body:
{
"username": "JohnDoe",
"email": "john@example.com",
"password": "password123"
}
Successful Response:
{
"status": "success",
"message": "Registration successful",
"user_id": 3,
"remember_token": "003d79783ce4b179921d5bf9effae716",
"totp_secret": "a006877c348443cba698",
"api_key": "0360c2393c91bf097905e71fbe382cbec508b840"
}
Error Response:
{
"status": "error",
"message": "All fields are required"
}
URL: list_apps.php
Method: GET
Headers:
Authorization: Bearer {JWT_TOKEN}Successful Response:
[
{
"app_name": "Google",
"created_at": "2025-03-05 14:54:45"
},
{
"app_name": "Grey",
"created_at": "2025-03-01 09:58:33"
}
]
Error Response:
{
"status": "error",
"message": "Token missing"
}
URL: generate_otp.php
Method: POST
Headers:
Authorization: Bearer {JWT_TOKEN}Content-Type: application/jsonRequest Body:
{
"app_name": "Google"
}
Successful Response:
{
"status": "success",
"otp": "123456"
}
Error Response:
{
"status": "error",
"message": "App not found"
}
URL: verify_otp.php
Method: POST
Headers:
Authorization: Bearer {JWT_TOKEN}Content-Type: application/jsonRequest Body:
{
"app_name": "Google",
"otp": "123456"
}
Successful Response:
{
"status": "success",
"message": "OTP is valid"
}
Error Response:
{
"status": "error",
"message": "Invalid OTP"
}
URL: scan_qr.php
Method: POST
Headers:
Authorization: Bearer {JWT_TOKEN}Content-Type: application/jsonRequest Body:
{
"app_name": "ExampleApp",
"secret": "JBSWY3DPEHPK3PXP"
}
Successful Response:
{
"status": "success",
"message": "QR code scanned successfully"
}
Error Response:
{
"status": "error",
"message": "Invalid QR code data"
}
URL: delete_app.php
Method: POST
Headers:
Authorization: Bearer {JWT_TOKEN}Content-Type: application/jsonRequest Body:
{
"app_name": "Google"
}
Successful Response:
{
"status": "success",
"message": "App deleted successfully"
}
Error Response:
{
"status": "error",
"message": "App not found"
}
URL: update_app.php
Method: POST
Headers:
Authorization: Bearer {JWT_TOKEN}Content-Type: application/jsonRequest Body:
{
"old_app_name": "Google",
"new_app_name": "GooglePlus",
"new_secret": "NEWSECRETKEY123"
}
Successful Response:
{
"status": "success",
"message": "App name updated successfully"
}
Error Response:
{
"status": "error",
"message": "Update failed"
}
URL: token_gen.php
Method: GET
Successful Response:
{
"status": "success",
"token": "generated_jwt_token_here"
}
Error Response:
{
"status": "error",
"message": "Token generation failed"
}
URL: verify_token_gen.php
Method: GET
Headers:
Authorization: Bearer {JWT_TOKEN}Successful Response:
{
"status": "success",
"message": "Token is valid"
}
Error Response:
{
"status": "error",
"message": "Invalid token"
}
Authorization header: Bearer {JWT_TOKEN}.AndroidManifest.xml, add:
<application android:usesCleartextTraffic="true" ...>
You can use Postman or cURL to test the API endpoints:
curl -X POST http://10.0.2.2/myauthenticator_api/mobile_api/login.php \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"user_password"}'
If testing on a real device, replace 10.0.2.2 with your PC's IP address.
10.0.2.2 for emulator or your PC's IP for a real device).JsonReader.setLenient(true), ensure your API returns valid JSON. You can enable lenient parsing in your Gson instance.This documentation provides the basic information required to interact with the myAuthenticator mobile API, including endpoints for login, registration, scanning QR codes, OTP generation/verification, and app management (delete and update), as well as token generation and verification. For any further questions or issues, please contact your API administrator or consult the project documentation.