Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: lib/src/handle_access_token_response.dart

Issue 1304363004: Code review changes (Closed) Base URL: git@github.com:dart-lang/oauth2.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/credentials.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.handle_access_token_response; 5 library oauth2.handle_access_token_response;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:http/http.dart' as http; 9 import 'package:http/http.dart' as http;
10 import 'package:http_parser/http_parser.dart'; 10 import 'package:http_parser/http_parser.dart';
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 var scope = parameters['scope']; 76 var scope = parameters['scope'];
77 if (scope != null) scopes = scope.split(" "); 77 if (scope != null) scopes = scope.split(" ");
78 78
79 var expiration = expiresIn == null ? null : 79 var expiration = expiresIn == null ? null :
80 startTime.add(new Duration(seconds: expiresIn) - _expirationGrace); 80 startTime.add(new Duration(seconds: expiresIn) - _expirationGrace);
81 81
82 return new Credentials( 82 return new Credentials(
83 parameters['access_token'], 83 parameters['access_token'],
84 parameters['refresh_token'], 84 refreshToken: parameters['refresh_token'],
85 tokenEndpoint, 85 tokenEndpoint: tokenEndpoint,
86 scopes, 86 scopes: scopes,
87 expiration); 87 expiration: expiration);
88 } 88 }
89 89
90 /// Throws the appropriate exception for an error response from the 90 /// Throws the appropriate exception for an error response from the
91 /// authorization server. 91 /// authorization server.
92 void _handleErrorResponse(http.Response response, Uri tokenEndpoint) { 92 void _handleErrorResponse(http.Response response, Uri tokenEndpoint) {
93 validate(condition, message) => 93 validate(condition, message) =>
94 _validate(response, tokenEndpoint, condition, message); 94 _validate(response, tokenEndpoint, condition, message);
95 95
96 // OAuth2 mandates a 400 or 401 response code for access token error 96 // OAuth2 mandates a 400 or 401 response code for access token error
97 // responses. If it's not a 400 reponse, the server is either broken or 97 // responses. If it's not a 400 reponse, the server is either broken or
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 void _validate( 138 void _validate(
139 http.Response response, 139 http.Response response,
140 Uri tokenEndpoint, 140 Uri tokenEndpoint,
141 bool condition, 141 bool condition,
142 String message) { 142 String message) {
143 if (condition) return; 143 if (condition) return;
144 throw new FormatException('Invalid OAuth response for "$tokenEndpoint": ' 144 throw new FormatException('Invalid OAuth response for "$tokenEndpoint": '
145 '$message.\n\n${response.body}'); 145 '$message.\n\n${response.body}');
146 } 146 }
OLDNEW
« no previous file with comments | « lib/src/credentials.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698