OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:http/http.dart' as http; | 7 import 'package:http/http.dart' as http; |
8 | 8 |
9 import 'client.dart'; | 9 import 'client.dart'; |
10 import 'authorization_exception.dart'; | 10 import 'authorization_exception.dart'; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 _state = _State.finished; | 233 _state = _State.finished; |
234 | 234 |
235 return await _handleAuthorizationCode(authorizationCode); | 235 return await _handleAuthorizationCode(authorizationCode); |
236 } | 236 } |
237 | 237 |
238 /// This works just like [handleAuthorizationCode], except it doesn't validate | 238 /// This works just like [handleAuthorizationCode], except it doesn't validate |
239 /// the state beforehand. | 239 /// the state beforehand. |
240 Future<Client> _handleAuthorizationCode(String authorizationCode) async { | 240 Future<Client> _handleAuthorizationCode(String authorizationCode) async { |
241 var startTime = new DateTime.now(); | 241 var startTime = new DateTime.now(); |
242 | 242 |
243 var headers = {}; | 243 var headers = <String, String>{}; |
244 | 244 |
245 var body = { | 245 var body = { |
246 "grant_type": "authorization_code", | 246 "grant_type": "authorization_code", |
247 "code": authorizationCode, | 247 "code": authorizationCode, |
248 "redirect_uri": this._redirectEndpoint.toString() | 248 "redirect_uri": this._redirectEndpoint.toString() |
249 }; | 249 }; |
250 | 250 |
251 if (_basicAuth && secret != null) { | 251 if (_basicAuth && secret != null) { |
252 headers["Authorization"] = basicAuthHeader(identifier, secret); | 252 headers["Authorization"] = basicAuthHeader(identifier, secret); |
253 } else { | 253 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // [AuthorizationCodeGrant.handleAuthorizationResponse] or | 296 // [AuthorizationCodeGrant.handleAuthorizationResponse] or |
297 // [AuthorizationCodeGrant.handleAuthorizationCode] have been called. | 297 // [AuthorizationCodeGrant.handleAuthorizationCode] have been called. |
298 static const finished = const _State("finished"); | 298 static const finished = const _State("finished"); |
299 | 299 |
300 final String _name; | 300 final String _name; |
301 | 301 |
302 const _State(this._name); | 302 const _State(this._name); |
303 | 303 |
304 String toString() => _name; | 304 String toString() => _name; |
305 } | 305 } |
OLD | NEW |