dart-lang / tools

This repository is home to tooling related Dart packages.
BSD 3-Clause "New" or "Revised" License
30 stars 21 forks source link

Password authentication exception. #324

Open willladislaw opened 5 years ago

willladislaw commented 5 years ago

Update: Happens only if there is a scope parameter present.

Exception thrown on line:

var credentials = await handleAccessTokenResponse( response, authorizationEndpoint, startTime, scopes, delimiter, getParameters: getParameters);

type '_CompactLinkedHashSet' is not a subtype of type 'List'

Response appears to be as expected:

String jsonStr = await response.body; print(jsonStr):

{\"access_token\":\"670d5dac-54a8-215a-8c3a-b13e1eff72bb\",\"token_type\":\"bearer\",\"expires_in\":40718,\"scope\":\"read_profile\"}


Future<Client> resourceOwnerPasswordGrant(
    Uri authorizationEndpoint, String username, String password,
    {String identifier,
    String secret,
    Iterable<String> scopes,
    bool basicAuth = true,
    CredentialsRefreshedCallback onCredentialsRefreshed,
    http.Client httpClient,
    String delimiter,
    Map<String, dynamic> getParameters(
        MediaType contentType, String body)}) async {
  delimiter ??= ' ';
  var startTime = new DateTime.now();

  var body = {
    "grant_type": "password",
    "username": username,
    "password": password
  };

  var headers = <String, String>{};

  if (identifier != null) {
    if (basicAuth) {
      headers['Authorization'] = basicAuthHeader(identifier, secret);
    } else {
      body['client_id'] = identifier;
      if (secret != null) body['client_secret'] = secret;
    }
  }

  if (scopes != null && scopes.isNotEmpty)
    body['scope'] = scopes.join(delimiter);

  if (httpClient == null) httpClient = new http.Client();
  var response = await httpClient.post(authorizationEndpoint,
      headers: headers, body: body);
  String jsonStr = await response.body;
  print(jsonStr);

  var credentials = await handleAccessTokenResponse(
      response, authorizationEndpoint, startTime, scopes, delimiter,
      getParameters: getParameters);
  return new Client(credentials,
      identifier: identifier,
      secret: secret,
      httpClient: httpClient,
      onCredentialsRefreshed: onCredentialsRefreshed);
}
thosakwe commented 5 years ago

I wonder if it has to do with {} being interpreted as a Set literal? You should post a stack trace.