Created
December 22, 2022 06:24
-
-
Save tank777/88cf97ed2877db5c19f1a053a3c8f69c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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