gpt4 book ai didi

oauth-2.0 - Dart:HttpException:无法解析 header 值

转载 作者:行者123 更新时间:2023-12-03 03:48:03 29 4
gpt4 key购买 nike

我得到一个

HttpException: Failed to parse header value



当使用 M2 release dart httpoauth2库调用http.Client.get(Uri)方法时。我正在尝试使用API​​执行 File: get。我成功地将授权请求重定向到基于控制台的简单http服务器上,以获取 token 。然后,以下代码导致异常:

oauth.Credentials credentials = new oauth.Credentials(code);
http.Client client = new oauth.Client(CLIENT_ID, CLIENT_SECRET, credentials);
Uri uri = new Uri("https://www.googleapis.com/drive/v2/files/$fileID");
Future<http.Response> result = client.get(uri);

以下是完整的堆栈跟踪:
HttpException: Failed to parse header value
Unhandled exception:
FutureUnhandledException: exception while executing Future
HttpException: Failed to parse header value
original stack trace:
null
#0 _FutureImpl._complete (bootstrap:844:11)
#1 _FutureImpl._complete (bootstrap:848:5)
#2 _FutureImpl._setException (bootstrap:873:14)
#3 _CompleterImpl.completeException (bootstrap:952:30)
#4 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#5 _FutureImpl._complete (bootstrap:832:22)
#6 _FutureImpl._complete (bootstrap:848:5)
#7 _FutureImpl._setException (bootstrap:873:14)
#8 _CompleterImpl.completeException (bootstrap:952:30)
#9 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#10 _FutureImpl._complete (bootstrap:832:22)
#11 _FutureImpl._complete (bootstrap:848:5)
#12 _FutureImpl._setException (bootstrap:873:14)
#13 _CompleterImpl.completeException (bootstrap:952:30)
#14 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#15 _FutureImpl._complete (bootstrap:832:22)
#16 _FutureImpl._complete (bootstrap:848:5)
#17 _FutureImpl._setException (bootstrap:873:14)
#18 _CompleterImpl.completeException (bootstrap:952:30)
#19 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#20 _FutureImpl._complete (bootstrap:832:22)
#21 _FutureImpl._complete (bootstrap:848:5)
#22 _FutureImpl._setException (bootstrap:873:14)
#23 _CompleterImpl.completeException (bootstrap:952:30)
#24 IOClient.send.<anonymous closure>.<anonymous closure> (package:http/src/io_client.dart:38:36)
#25 _FutureImpl._complete (bootstrap:840:19)
#26 _FutureImpl._complete (bootstrap:848:5)
#27 _FutureImpl._setValue (bootstrap:862:14)
#28 _CompleterImpl.complete (bootstrap:949:26)
#29 async.<anonymous closure> (package:http/src/utils.dart:173:41)
#30 _Timer._createTimerHandler._handleTimeout (dart:io:7035:28)
#31 _Timer._createTimerHandler._handleTimeout (dart:io:7043:7)
#32 _Timer._createTimerHandler.<anonymous closure> (dart:io:7051:23)
#33 _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)

最佳答案

要使用Google Drive SDK API,您可以使用Google APIs Client Library for Dart,它允许从Dart应用程序访问Google API。

https://github.com/Scarygami/dart-google-oauth2-library是基于此构建的,它可以替代。

关于oauth-2.0 - Dart:HttpException:无法解析 header 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14116857/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com