我需要从这个字符串中可靠地获取访问令牌。
final authString = "myApp:%23access_token=abcd1234asdf1qwerty&scope=channel_feed_read&token_type=bearer"
我已经把它解码了 Uri.decodeComponent(authString)
但我不知道如何从URL片段中获取Auth token。
谅谅
你可以把它换成 #
与 ?
解码后,将查询参数作为一个普通的Uri进行解析。
final link = 'myApp:%23access_token=abcd1234asdf1qwerty&scope=channel_feed_read&token_type=bearer';
final decoded = Uri.decodeFull(link).replaceAll('#', '?');
final uri = Uri.parse(decoded);
final access_token = uri.queryParameters['access_token'];
final token_type = uri.queryParameters['token_type']
final scope = uri.queryParameters['scope'];