felixjunghans / google_speech

Flutter google spech
MIT License
68 stars 41 forks source link

Feature/auth via third party and token #42

Closed juarezfranco closed 1 year ago

juarezfranco commented 1 year ago

Added support via third-party and token-based authentication.

Fixed security issue by avoiding storing Google Account Service credentials within the application; instead, the token is obtained from a third-party API

Ref.: #8 #41

Via Third Party Authenticator

final speechToText = SpeechToText.viaThirdPartyAuthenticator(
      ThirdPartyAuthenticator(
        obtainCredentialsFromThirdParty: () async {
          // request api to get token
          final resultExample = '{
            "accessToken": {
              "type": "Bearer",
              "data": "<token-here>",
              "expiry": "2024-05-28T23:59:59.0000000Z",
            },
            "scopes": [
              "https://www.googleapis.com/auth/cloud-platform",
            ],
          }';
          return AccessCredentials.fromJson(resultExample);
        },
      ),
    );

Via Token (bonus)

    final speechToText = SpeechToText.viaToken(
      'Bearer',
      '<token-here>',
    );
LucienCorreia commented 1 year ago

UP!

felixjunghans commented 1 year ago

Thanks again. I will update the documentation and then release a new version.