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 credentials; | 5 library credentials; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:json' as JSON; | 8 import 'dart:json' as JSON; |
9 import 'dart:uri'; | 9 import 'dart:uri'; |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 validate(value == null || value is String, | 98 validate(value == null || value is String, |
99 'field "$stringField" was not a string, was "$value"'); | 99 'field "$stringField" was not a string, was "$value"'); |
100 } | 100 } |
101 | 101 |
102 var scopes = parsed['scopes']; | 102 var scopes = parsed['scopes']; |
103 validate(scopes == null || scopes is List, | 103 validate(scopes == null || scopes is List, |
104 'field "scopes" was not a list, was "$scopes"'); | 104 'field "scopes" was not a list, was "$scopes"'); |
105 | 105 |
106 var tokenEndpoint = parsed['tokenEndpoint']; | 106 var tokenEndpoint = parsed['tokenEndpoint']; |
107 if (tokenEndpoint != null) { | 107 if (tokenEndpoint != null) { |
108 tokenEndpoint = new Uri.fromString(tokenEndpoint); | 108 tokenEndpoint = Uri.parse(tokenEndpoint); |
109 } | 109 } |
110 var expiration = parsed['expiration']; | 110 var expiration = parsed['expiration']; |
111 if (expiration != null) { | 111 if (expiration != null) { |
112 validate(expiration is int, | 112 validate(expiration is int, |
113 'field "expiration" was not an int, was "$expiration"'); | 113 'field "expiration" was not an int, was "$expiration"'); |
114 expiration = new Date.fromMillisecondsSinceEpoch(expiration); | 114 expiration = new Date.fromMillisecondsSinceEpoch(expiration); |
115 } | 115 } |
116 | 116 |
117 return new Credentials( | 117 return new Credentials( |
118 parsed['accessToken'], | 118 parsed['accessToken'], |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (credentials.refreshToken != null) return credentials; | 183 if (credentials.refreshToken != null) return credentials; |
184 return new Credentials( | 184 return new Credentials( |
185 credentials.accessToken, | 185 credentials.accessToken, |
186 this.refreshToken, | 186 this.refreshToken, |
187 credentials.tokenEndpoint, | 187 credentials.tokenEndpoint, |
188 credentials.scopes, | 188 credentials.scopes, |
189 credentials.expiration); | 189 credentials.expiration); |
190 }); | 190 }); |
191 } | 191 } |
192 } | 192 } |
OLD | NEW |