Custom Authentication
Learn how to integrate a full authentication flow within your application.
To allow users to authenticate their accounts from within your application, the steps will vary depending on the authentication flow used by the provider:
- Credentials Flow : The provider accepts a set of credentials—such as a username and password, tokens, or connection parameters. During this process, the provider may also require the user to solve additional challenges like Two-Factor Authentication (2FA), One-Time Passwords (OTP), CAPTCHAs, or in-app validations.
- QR Code Flow : The provider returns a QR code that must be displayed to the user. Your application should wait until the code is scanned and the authentication is completed. Each QR code have a short living time and must be refreshed when expired.
- OAuth Flow: The provider uses a standard OAuth process, which involves redirecting the user to a login and consent screen. Once the user grants permission, they are redirected back to your application.
Full example project on GithubExplore a complete example project used to support this guide on GitHub:https://github.com/unipile/unipile-auth-example
Here is what flow is used by each Provider. Follow the guide accordingly.
| Provider | Flow |
|---|---|
| Credentials Flow | |
| IMAP | Credentials Flow |
| Credentials Flow | |
| QR Code Flow | |
| Telegram | QR Code Flow |
| OAuth Flow | |
| Microsoft Outlook | OAuth Flow |
Configure proxy & location
When starting a Custom Authentication flow, you can provide a custom proxy or choose the location of the automatic proxy in the config field of the Start Auth Intent request. Unlike Hosted Authentication, the provider is already specified by the provider field, so the configuration does not need to be nested under a provider name.
config.custom_proxyspecifies a proxy to use for the account. It takes precedence over any automatic proxy.config.auto_proxy_configspecifies the country of the automatic proxy, either directly withcountryor by inferring it fromip. When usingip, provide the end user's public IP address, not the IP address of your application server. Automatic proxy protection currently applies to LinkedIn, WhatsApp, and Instagram.
For example, start a LinkedIn authentication intent through a custom proxy:
const response = await customAuthApi.startAuthIntent({
body: {
provider: "linkedin",
credentials: {
username: "username",
password: "password",
},
config: {
custom_proxy: {
host: "1.1.1.1",
port: 5100,
protocol: "https",
},
},
},
});curl --request POST \
--url https://api.unipile.com/v2/auth/intent \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"provider": "linkedin",
"credentials": {
"username": "username",
"password": "password"
},
"config": {
"custom_proxy": {
"host": "1.1.1.1",
"port": 5100,
"protocol": "https"
}
}
}
'To use automatic proxy protection in a specific location instead, omit custom_proxy and pass an ISO 3166-1 alpha-2 country code, for example config.auto_proxy_config.country = "FR".
For more details on custom proxies, automatic proxies, and the lookup order used to determine which proxy is applied, see our Proxy guide.
Updated 1 day ago