Class GooglePlayAuthenticationProvider
- Namespace
- VpnHood.AppLib.Stores.GooglePlay
- Assembly
- VpnHood.AppLib.Stores.GooglePlay.dll
Provides the sign-in with Google, through Android's Credential Manager, which gives Google's ID token.
public class GooglePlayAuthenticationProvider : IAuthenticationExternalProvider, IDisposable
- Inheritance
-
GooglePlayAuthenticationProvider
- Implements
- Inherited Members
Constructors
GooglePlayAuthenticationProvider(string)
Provides the sign-in with Google, through Android's Credential Manager, which gives Google's ID token.
public GooglePlayAuthenticationProvider(string googleSignInClientId)
Parameters
googleSignInClientIdstringThe server's OAuth client ID, which Google issues the ID token for.
Properties
ProviderId
The identity provider this implementation drives, self-declared as a free-form string id (lowercase by convention; see AuthProviders for the well-known ones) so nothing downstream ever hardcodes it: the portal sends it verbatim as the wire discriminator, AppDescriptor reports it, and the UI picks the matching "Sign in with X" label. A string rather than an enum so a third-party app on these packages can add its own provider — no library change, no consumer changes.
public string ProviderId { get; }
Property Value
Remarks
It is Google.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
SignIn(IUiContext?, bool, CancellationToken)
Signs the person in with the identity provider.
public Task<string> SignIn(IUiContext? uiContext, bool isSilentLogin, CancellationToken cancellationToken)
Parameters
uiContextIUiContextThe window, or null where none is open.
isSilentLoginbooltrue where the person did not ask to sign in, as for a renewal, so the provider avoids a prompt where it can.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Remarks
It first asks for a Google ID credential, which is picked without the person where
isSilentLogin is true and the device allows it; where the device offers none
and the sign-in is not silent, it shows the "Sign in with Google" sheet.
Exceptions
- UiContextNotAvailableException
uiContextis null, and the provider shows a sheet.- AuthenticationException
The identity provider gave no ID token, as Google's where the device has no Google account.
- InvalidOperationException
isSilentLoginis true where the provider cannot sign in without the person, as Apple's while the app is not in front.- OperationCanceledException
The person canceled the sign-in, or
cancellationTokenwas canceled.- AuthenticationException
The device has no Google account, or Google's sign-in failed.
- NoCredentialException
The sign-in is silent, and the device offers no credential.
- ApiException
The Credential Manager failed.
- InvalidOperationException
The activity has no main executor, or the Credential Manager gave no response, or one of another type.
SignOut(IUiContext?, CancellationToken)
Clears the identity provider's sign-in on this device, where it keeps one.
public Task SignOut(IUiContext? uiContext, CancellationToken cancellationToken)
Parameters
uiContextIUiContextThe window, or null where none is open.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
It clears the Credential Manager's sign-in state for the app.
Exceptions
- UiContextNotAvailableException
uiContextis null, and the provider needs a window to clear it.- ApiException
The platform failed to clear it, as Google's credential manager reports a failure or a cancel.
- InvalidOperationException
The activity has no main executor.