我得到了
HttpException:无法解析标头值
使用M2 release dart http和oauth2库调用http.Client.get(Uri)方法时。我正在尝试使用API来执行File: get。我成功地将我的授权请求重定向到一个简单的基于控制台的http服务器以获取令牌。然后,以下代码导致异常:
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)
答案 0 :(得分:1)
要使用Google Drive SDK API,您可以使用Google APIs Client Library for Dart从Dart应用程序访问Google API。
https://github.com/Scarygami/dart-google-oauth2-library是基于此构建的,它可以作为替代方案。
答案 1 :(得分:0)
您可能没有初始化SSL?
SecureSocket.initialize();
有关详细信息,请参阅http://api.dartlang.org/docs/bleeding_edge/dart_io/SecureSocket.html。