Skip to content

Instantly share code, notes, and snippets.

@tank777
Created December 22, 2022 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tank777/88cf97ed2877db5c19f1a053a3c8f69c to your computer and use it in GitHub Desktop.
Save tank777/88cf97ed2877db5c19f1a053a3c8f69c to your computer and use it in GitHub Desktop.
import 'package:http/http.dart' as http;
Future<String> getIdToken({bool? force}) async {
// fetch update token
return "abc*******";
}
Future<void> main() async {
final client = http.Client();
final token = await getIdToken();
final response = await client.get(Uri.parse("https://senkyaku.jp"), headers: {
'Authentication': 'Bearer $token'
});
if(response.statusCode == 401) {
throw Exception('reacquire the token and try again');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment