Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate the createScopedRequired methods #410

Merged
merged 4 commits into from
Jul 11, 2018
Merged

fix: deprecate the createScopedRequired methods #410

merged 4 commits into from
Jul 11, 2018

Conversation

JustinBeckwith
Copy link
Contributor

BREAKING CHANGE: The createScopedRequired method has been deprecated on multiple classes. The createScopedRequired and createScoped methods on the JWT class were largely in place to help inform clients when scopes were required in an application default credential scenario. Instead of checking if scopes are required after creating the client, instead scopes should just be passed either into the GoogleAuth.getClient method, or directly into the JWT constructor.

Old code

auth.getApplicationDefault(function(err, authClient) {
   if (err) {
     return callback(err);
   }
  if (authClient.createScopedRequired && authClient.createScopedRequired()) {
    authClient = authClient.createScoped([
      'https://www.googleapis.com/auth/cloud-platform'
    ]);
  }
  callback(null, authClient);
});

New code

const client = await auth.getClient({
  scopes: ['https://www.googleapis.com/auth/cloud-platform']
});

@JustinBeckwith JustinBeckwith requested review from ofrobots and a team July 6, 2018 19:48
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 6, 2018
@codecov-io
Copy link

codecov-io commented Jul 6, 2018

Codecov Report

Merging #410 into master will increase coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #410      +/-   ##
==========================================
+ Coverage   94.87%   95.15%   +0.28%     
==========================================
  Files          15       15              
  Lines         956      970      +14     
  Branches      217      217              
==========================================
+ Hits          907      923      +16     
+ Misses         49       47       -2
Impacted Files Coverage Δ
src/messages.ts 100% <100%> (ø) ⬆️
src/auth/computeclient.ts 95% <100%> (+0.26%) ⬆️
src/auth/iam.ts 100% <100%> (+25%) ⬆️
src/auth/jwtclient.ts 95.04% <100%> (+0.2%) ⬆️
src/auth/jwtaccess.ts 98.18% <100%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a96bca9...7b9cbd0. Read the comment docs.

@JustinBeckwith JustinBeckwith requested a review from a team July 11, 2018 04:49
@JustinBeckwith
Copy link
Contributor Author

gentle ping @google/google-node-team @google/yoshi-nodejs

Copy link
Contributor

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/ nits.

/**
* Determine if there are currently scopes available.
*/
protected hasScopes() {

This comment was marked as spam.

@@ -40,6 +42,7 @@ export class IAMAuth {
*/
createScopedRequired() {

This comment was marked as spam.

].join(' ')
};

export const JWT_CREATE_SCOPED_DEPRECATED = {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@JustinBeckwith JustinBeckwith merged commit 63f4b38 into googleapis:master Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants