0
  • I have downloaded the service account json from Google Cloud and stored it in my assets folder.
  • I well have the rules "Secret Manager Secret Accessor" et "Secret Manager Viewer" enable in my google cloud project

Here is my code :

const String secretsPath = 'projects/"project-id"/secrets/smtp_password/versions/latest';
    final credentials = json.decode(await rootBundle.loadString('assets/json/google-service-account.json'));
    final AutoRefreshingAuthClient client = await clientViaServiceAccount(
        ServiceAccountCredentials.fromJson(credentials),
        [SecretManagerApi.cloudPlatformScope],
        baseClient: http.Client());
    final SecretManagerApi api = SecretManagerApi(client);

    final AccessSecretVersionResponse secrets = await api.projects.secrets.versions.access(secretsPath);
    final String decoded = utf8.decode(base64Url.decode(secrets.payload!.data!));

But I am having this error :

"DetailedApiRequestError(status: 403, message: Permission 'secretmanager.versions.access' denied for resource 'projects/"project- id"/secrets/smtp_password/versions/latest' (or it may not exist).)"

What am I missing ?

ChloƩ
  • 331
  • 1
  • 5
  • 14

0 Answers0