| 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 library oauth2_client; | 5 library oauth2_client; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:uri'; | 8 import 'dart:uri'; |
| 9 | 9 |
| 10 import 'package:http/http.dart' as http; | 10 import 'package:http/http.dart' as http; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return response; | 103 return response; |
| 104 } | 104 } |
| 105 | 105 |
| 106 if (authenticate.scheme != 'bearer') return response; | 106 if (authenticate.scheme != 'bearer') return response; |
| 107 | 107 |
| 108 var params = authenticate.parameters; | 108 var params = authenticate.parameters; |
| 109 if (!params.containsKey('error')) return response; | 109 if (!params.containsKey('error')) return response; |
| 110 | 110 |
| 111 throw new AuthorizationException( | 111 throw new AuthorizationException( |
| 112 params['error'], params['error_description'], | 112 params['error'], params['error_description'], |
| 113 Uri.parse(params['error_uri'])); | 113 params['error_uri'] == null ? null : Uri.parse(params['error_uri'])); |
| 114 }); | 114 }); |
| 115 } | 115 } |
| 116 | 116 |
| 117 /// Explicitly refreshes this client's credentials. Returns this client. | 117 /// Explicitly refreshes this client's credentials. Returns this client. |
| 118 /// | 118 /// |
| 119 /// This will throw a [StateError] if the [Credentials] can't be refreshed, an | 119 /// This will throw a [StateError] if the [Credentials] can't be refreshed, an |
| 120 /// [AuthorizationException] if refreshing the credentials fails, or a | 120 /// [AuthorizationException] if refreshing the credentials fails, or a |
| 121 /// [FormatError] if the authorization server returns invalid responses. | 121 /// [FormatError] if the authorization server returns invalid responses. |
| 122 /// | 122 /// |
| 123 /// You may request different scopes than the default by passing in | 123 /// You may request different scopes than the default by passing in |
| (...skipping 14 matching lines...) Expand all Loading... |
| 138 return this; | 138 return this; |
| 139 }); | 139 }); |
| 140 } | 140 } |
| 141 | 141 |
| 142 /// Closes this client and its underlying HTTP client. | 142 /// Closes this client and its underlying HTTP client. |
| 143 void close() { | 143 void close() { |
| 144 if (_httpClient != null) _httpClient.close(); | 144 if (_httpClient != null) _httpClient.close(); |
| 145 _httpClient = null; | 145 _httpClient = null; |
| 146 } | 146 } |
| 147 } | 147 } |
| OLD | NEW |