You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Description
This PR adds support for the Nylas provider detection endpoint that
allows users to pass in an email address and get the provider that
matches it. This is especially helpful for users that implement native
authentication. This change also enhances the `ProviderSettings` class
by introducing a new static method that is able to match a provider
setting by the provider string
(`ProviderSettings.getProviderSettingsByProvider`). There's also an enum
with all the providers supported for the native authentication flow
(`NativeAuthentication.Provider`).
# Usage
```java
// Set up your client
NylasClient client = new NylasClient();
NativeAuthentication nativeAuthentication = client.application("CLIENT_ID", "CLIENT_SECRET").nativeAuthentication();
// Detect the provider for an email address
NativeAuthentication.DetectedProvider detectedProvider = nativeAuthentication.detectProvider("test@gmail.com");
// The following fields are made available
detectedProvider.isDetected();
detectedProvider.getProviderName();
detectedProvider.getAuthName();
detectedProvider.getEmailAddress();
detectedProvider.isImap();
// You can use the result from above to get the correct provider settings
ProviderSettings detectedSettings = ProviderSettings.getProviderSettingsByProvider(provider.getAuthName());
// The enum is provided for consistency and equality
if(detectedProvider.getAuthName() == NativeAuthentication.Provider.GMAIL.getName()) {
// do something here for a Gmail case
}
```
# License
<!-- Your PR comment must contain the following line for us to merge the
PR. -->
I confirm that this contribution is made under the terms of the MIT
license and that I have the authority necessary to make this
contribution on behalf of its copyright owner.
0 commit comments