Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Throw a better error when a serviceAccount ClientId is used with obtainAccessCredentialsViaUserConsentManual #17

Open
kevmoo opened this issue Jun 19, 2015 · 1 comment

Comments

@kevmoo
Copy link
Contributor

kevmoo commented Jun 19, 2015

The URL encoding fails with a an unhelpful error because the ClientId has a null secret.

The null object does not have a getter 'length'.

NoSuchMethodError: method not found: 'length'
Receiver: null
Arguments: []
dart:core                                                       Uri.encodeQueryComponent
package:googleapis_auth/src/oauth2_flows/auth_code.dart 54:28   obtainAccessCredentialsUsingCode
package:googleapis_auth/src/oauth2_flows/auth_code.dart 123:12  AuthorizationCodeGrantAbstractFlow._obtainAccessCredentialsUsingCode
package:googleapis_auth/src/oauth2_flows/auth_code.dart 260:14  AuthorizationCodeGrantManualFlow.run.<fn>
@Pacane
Copy link

Pacane commented Aug 7, 2015

Shouldn't this not throw an error at all? I thought we didn't need to provide a secret when using a serviceAccount, am I wrong?

I feel like

Future<AccessCredentials> obtainAccessCredentialsUsingCode(
    ClientId clientId, String code, String redirectUrl, http.Client client,
    [List<String> scopes]) {
  var uri = Uri.parse('https://accounts.google.com/o/oauth2/token');
  var formValues = [
      'grant_type=authorization_code',
      'code=${Uri.encodeQueryComponent(code)}',
      'redirect_uri=${Uri.encodeQueryComponent(redirectUrl)}',
      'client_id=${Uri.encodeQueryComponent(clientId.identifier)}',
      'client_secret=${Uri.encodeQueryComponent(clientId.secret)}',
  ];
// ....

should do a null check for clientId.secret before encoding it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants