OAuth Registration

Register and authenticate users with Google or Microsoft accounts
View as Markdown

Vlens supports OAuth 2.0 authentication via Google and Microsoft (Azure AD B2C). Users can register and log in using an existing social account — skipping the email OTP verification step.


Setup

OAuth providers must be configured in the Vlens portal before use:

Contact your Vlens administrator to enable and link the client credentials to your tenant.


How it works


Step 1 — Verify the OAuth token

After your app obtains an ID token from the provider, send it to Vlens for verification:

$curl -X POST https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyOAuthToken \
> -H "ApiKey: YOUR_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "provider": "Google",
> "IdToken": "OAUTH_ID_TOKEN_FROM_PROVIDER"
> }'

Response:

1{
2 "data": {
3 "oAuthTokenVerificationRequestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
4 "isVerified": true,
5 "validationResult": "Token verified successfully",
6 "email": "user@gmail.com"
7 },
8 "error_code": null
9}

Save oAuthTokenVerificationRequestId — it is required in Step 2.


Step 2 — Complete registration

Pass the oAuthTokenVerificationRequestId alongside the standard StepCreate fields. This replaces the emailOtpRequestId — email is already verified by the OAuth provider.

$curl -X POST https://api.vlenseg.com/api/DigitalIdentity/Register/StepCreate \
> -H "ApiKey: YOUR_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "geoLocation": { "latitude": 30.0444, "longitude": 31.2357 },
> "imei": "DEVICE_ID",
> "password": "USER_PASSWORD",
> "phoneNumberOtpRequestId": "PHONE_OTP_REQUEST_ID",
> "oAuthTokenVerificationRequestId": "SAVED_OAUTH_REQUEST_ID"
> }'

On success the user is registered and a user access token is returned — same as the standard registration flow.


Skip email for an existing user

If a user is already registered but has not verified their email, use VerifyOAuthToken to verify the email via OAuth instead of sending an email OTP:

$curl -X POST https://api.vlenseg.com/api/DigitalIdentity/VerifyOAuthToken \
> -H "ApiKey: YOUR_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "provider": "Microsoft",
> "IdToken": "OAUTH_ID_TOKEN"
> }'

The response is the same shape as StepVerifyOAuthToken — use the returned oAuthTokenVerificationRequestId to complete the pending registration step.


Supported providers

Providerprovider value
Google"Google"
Microsoft (Azure AD B2C)"Microsoft"

Standard registration comparison

StepStandard flowOAuth flow
Send phone OTPRegister/StepVerifyPhone (send)Same
Validate phone OTPRegister/StepVerifyPhone (validate)Same
Verify emailRegister/StepVerifyEmailReplaced by Register/StepVerifyOAuthToken
Complete registrationRegister/StepCreateSame — pass oAuthTokenVerificationRequestId