Reputation: 21
i want connect google cloud Vision to my flutter app
this is my code
import 'package:dio/dio.dart';
const _apiPREFIX = "https://vision.googleapis.com";
class Server {
Future<void> postReq() async {
Response response;
Dio dio = Dio();
Map<String, dynamic> data = {
"requests": [
{
"image": {
"source": {
"imageUri":
"https://image.msscdn.net/images/goods_img/20200729/1530505/1530505_2_500.jpg?t=20210902101946"
}
},
"features": [
{"type": "LABEL_DETECTION", "maxResults": 1}
]
}
]
};
try {
response = await dio.post(
"$_apiPREFIX/v1/images:asyncBatchAnnotate?key=(my api key)",data: data
);
print(response.data.toString());
} catch (e) {
print(e);
}
}
}
Server server = Server();
i have google Api key but how can use this key
i recieve 403 error how can i fix this problem,,,
please help
Upvotes: 1
Views: 1350
Reputation: 11
Maybe you should use this package to retrieve the authentication tokens and pass it in the request.
Package: https://pub.dev/packages/gcloud/install
More details: https://cloud.google.com/vision/docs/ocr#curl
Upvotes: 1