A flutter plug-in for the native Auth-Core library (Android and iOS).


First, add auth_flutter as a dependency in your pubspec.yaml file.


Add TekoGoogleRegistryToken to of this project (contact to get the token).

// android/


In project build.grade. Add the following code:

allprojects {
  repositories {

    Properties properties = new Properties()

    maven {

      authentication {

      credentials {
        username = "_json_key_base64"
        password = properties.getProperty('TekoGoogleRegistry.password')


Setup github access token for accessing Teko iOS frameworks (contact to get the token)..

  • Open terminal: touch /.bash_profile; open /.bash_profile (a text editor will be opened)
  • Add a new line: export GITHUB_USER_TOKEN="<your-token>"
  • Save file and go back to terminal: source ~/.bash_profile

Library usage

Get an Auth instance

Static Method: `TerraAuth.getInstance(String appName) → Future

Should be called in initialize phase of your app and must be called after initilizing TerraApp successful.

Check login state

Method: isAuthorized() -> Future<Result<bool, Exception>>

Check whether current app is authorized or not

Get access token

Method: getAccessToken() -> Future<Result<IamToken, Exception>>

Get saved access token.

Refresh token

Method: refreshToken() -> Future<Result<IamToken, Exception>>

Refresh current token (Should call this function after the current token is expired) Return new access token if success.

Exchange token

Method: exchangeToken() -> Future<Result<IdToken, Exception>>

Create a new id-token from iamAudience that was set on IAM console

Request otp

Method: requestOtp() -> Future<Result<Object, Exception>>

request send a OTP to a specific phone number to login.

Login with credential

Method: loginWithCredential(LoginCredential credential) -> Future<Result<bool, Exception>>

There are 6 types of credential:

  • AppleCredential (should be created from AppleProvider.createCredential(String accessToken))
  • FacebookCredential (should be created from FacebookProvider.createCredential(String accessToken))
  • GoogleCredential (should be created from GoogleProvider.createCredential(String accessToken))
  • PhoneOtpCredential (should be created from PhoneOtpProvider.createCredential(String phoneNumber, String otp))
  • UsernamePasswordCredential (should be created from UsernamePasswordProvider.createCredential(String username, String password))
  • CustomCredential (should be created from CustomProvider.createCredential(String idToken))

Login Google directly

Method: loginWithGoogle() -> Future<Result<bool, Exception>>

Login Facebook directly

Method: loginWithFacebook() -> Future<Result<bool, Exception>>

Login Apple directly

Method: loginWithApple() -> Future<Result<bool, Exception>>


Method: `logout() -> Future<Result<bool, Exception>>

Perform logging out.