Authentication
The Cirvia Parental SDK uses Google OAuth for secure user authentication. This ensures that only authorized users can access the content moderation features and that parent accounts are properly linked to monitored content.
Overview​
The authentication flow works as follows:
- User Consent: App shows onboarding dialog explaining content moderation
- Google Sign-In: User authenticates via Google OAuth
- Token Exchange: Google ID token is sent to Cirvia backend
- User Creation: Backend creates or retrieves user account
- SDK Ready: SDK is initialized and ready to monitor content
Google OAuth Setup​
Step 1: Firebase Console Configuration​
- Go to Firebase Console
- Select your project (or create new one)
- Navigate to Authentication → Sign-in method
- Enable Google sign-in provider
- Add your app's SHA-1 fingerprint
Step 2: Get SHA-1 Fingerprint​
Debug Fingerprint​
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Release Fingerprint​
keytool -list -v -keystore /path/to/your/keystore.jks -alias your_alias_name
Step 3: Download Configuration​
- In Firebase Console, go to Project Settings
- Download
google-services.json - Place in your app's
app/directory
SDK Authentication Flow​
Automatic Authentication​
The SDK handles authentication automatically when you call ParentalAI.init():
import com.cirvia.parentalai.ParentalAI;
import com.cirvia.parentalai.config.ParentalAIConfig;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeParentalAI();
}
private void initializeParentalAI() {
ParentalAIConfig config = new ParentalAIConfig(
"your-api-key",
"your-ingest-endpoint",
"your-auth-endpoint",
BuildConfig.DEBUG
);
ParentalAI.init(this, config,
() -> {
// Authentication and initialization successful
Log.d("Auth", "Cirvia Parental ready to use");
onSDKReady();
},
() -> {
// User declined or authentication failed
Log.w("Auth", "Cirvia Parental initialization declined");
onSDKDeclined();
}
);
}
private void onSDKReady() {
// SDK is ready - you can now monitor content
// Enable content monitoring features in your UI
}
private void onSDKDeclined() {
// Handle case where user declined authentication
// You might want to disable certain features or show info dialog
}
}
Understanding the Authentication Dialog​
When ParentalAI.init() is called, users see this dialog:
Parental Moderation Notice
This app uses Cirvia Parental for content moderation.
Would you like to continue?
[Continue] [Cancel]
Customizing the Dialog Message​
The default message can be customized by modifying the SDK source or by implementing your own pre-authentication flow:
private void showCustomOnboardingDialog() {
new AlertDialog.Builder(this)
.setTitle("Child Safety Features")
.setMessage("To keep our community safe for children, we use AI-powered content moderation. This helps parents monitor their child's online activities. Continue?")
.setPositiveButton("I Understand", (dialog, which) -> {
// User agreed, now initialize SDK
initializeParentalAI();
})
.setNegativeButton("Learn More", (dialog, which) -> {
// Show more information or link to privacy policy
showPrivacyInfo();
})
.show();
}
User Account Management​
User Data​
Once authenticated, the SDK receives a User object with:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "parent@example.com",
"name": "John Doe",
"picture": "https://lh3.googleusercontent.com/..."
}
Account Linking​
The authenticated user becomes the "parent" account that will receive incident notifications. All content monitored by your app will be associated with this parent account.
Authentication States​
Checking Authentication Status​
public class MyApplication extends Application {
private boolean isParentalAIReady = false;
public boolean isContentMonitoringAvailable() {
return isParentalAIReady;
}
public void initializeSDK() {
ParentalAI.init(this, config,
() -> {
isParentalAIReady = true;
notifySDKReady();
},
() -> {
isParentalAIReady = false;
notifySDKDeclined();
}
);
}
}
Handling Authentication Failure​
private void handleAuthenticationFailure() {
Log.e("Auth", "Cirvia Parental authentication failed");
// Options for handling failure:
// Option 1: Continue without content moderation
proceedWithoutModeration();
// Option 2: Show retry dialog
showRetryDialog();
// Option 3: Require authentication to use app
requireAuthentication();
}
private void showRetryDialog() {
new AlertDialog.Builder(this)
.setTitle("Authentication Required")
.setMessage("Content moderation features require authentication. Try again?")
.setPositiveButton("Retry", (dialog, which) -> initializeParentalAI())
.setNegativeButton("Skip", (dialog, which) -> proceedWithoutModeration())
.show();
}
Privacy and Compliance​
Data Collection​
The SDK collects:
- User Profile: Email, name, profile picture (from Google)
- Content Data: Text and images sent for moderation
- Platform Info: Which platform/app the content came from
- Risk Scores: AI-generated risk assessments
COPPA Compliance​
For apps with users under 13:
- Obtain verifiable parental consent before authentication
- Clearly explain data collection in your privacy policy
- Provide parents with access to their child's data
- Allow parents to delete their child's data
Example Privacy Notice​
private void showPrivacyNotice() {
String message = "We use Cirvia Parental to help keep children safe online. " +
"This service:\n\n" +
"• Analyzes messages and images for inappropriate content\n" +
"• Sends alerts to parents about potential risks\n" +
"• Stores content data securely for review\n\n" +
"Parents can view, manage, and delete this data at any time through the parent dashboard.";
new AlertDialog.Builder(this)
.setTitle("Privacy & Child Safety")
.setMessage(message)
.setPositiveButton("View Privacy Policy", (dialog, which) -> openPrivacyPolicy())
.setNegativeButton("Continue", (dialog, which) -> initializeParentalAI())
.show();
}
Troubleshooting Authentication​
Common Issues​
"Google account not available or token missing"
- Ensure Google Play Services is installed and updated
- Check that user is signed into Google account on device
- Verify
google-services.jsonis properly configured
"Authentication failed" or network errors
- Check internet connectivity
- Verify API endpoints are correct
- Ensure API key is valid and active
"Invalid ID token" errors
- Check SHA-1 fingerprint is registered in Firebase
- Verify package name matches Firebase configuration
- Ensure system time is correct on device
Debug Authentication​
Enable debug logging to troubleshoot:
ParentalAIConfig config = new ParentalAIConfig(
apiKey,
ingestEndpoint,
authEndpoint,
true // Enable debug logging
);
Check logs for authentication flow:
adb logcat | grep -E "(ParentalAI|GoogleSignIn)"
Next Steps​
Now that authentication is configured:
- API Reference → - Learn all SDK methods
- Text Monitoring → - Monitor chat and messages
- Image Monitoring → - Analyze photos and media
- Platform Integration → - Platform-specific examples
Getting Help​
- Authentication Issues: Check Troubleshooting Guide
- Privacy Questions: Email privacy@cirvia.co
- Technical Support: Email info@cirvia.co
- Parent Dashboard: cirvia.vercel.app
Authentication setup complete? Continue to the API Reference to learn about all available SDK methods.