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] scopes comma-delimited to space-delimited #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gardun0
Copy link

@gardun0 gardun0 commented Oct 9, 2018

As the documentation reference from JavaScript Google API Client says:

"The scopes to request, as a space-delimited string."

https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiclientinitargs

Copy link
Owner

@lourd lourd left a comment

Choose a reason for hiding this comment

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

Hey, thanks so much for your pull request!

Good catch on the wrong scopes delimiter. I'm happy to merge that change in after the test is corrected. Can you update the snapshot as well? You can do that with by running yarn test --updateSnapshot (which runs jest --updateSnapshot. See more here)

The other changes have a few things that need to be addressed; see my comments. We can move those to another PR if you want the scopes correct in more quickly.

@@ -1,12 +1,15 @@
{
"name": "@lourd/react-google-api",
"name": "@not/react-google-api",
Copy link
Owner

Choose a reason for hiding this comment

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

No need to change this

this.auth.grantOfflineAccess({
scope: `${this.props.scopes.join(' ')}`,
prompt: 'select_account'
}).then(({code }) => this.setState({ code }))
Copy link
Owner

Choose a reason for hiding this comment

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

What should happen if the promise rejects?

Copy link
Owner

Choose a reason for hiding this comment

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

Also what is the code parameter here?

}).then(({code }) => this.setState({ code }))
}

if (!this.props.offline) this.auth.signIn()
Copy link
Owner

Choose a reason for hiding this comment

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

These blocks can be simplified:

if (this.auth) {
  if (this.props.offline) {
    // grantOfflineAccess
  } else {
    this.auth.signIn()
  }
}

@@ -62,6 +72,8 @@ class GoogleApi extends React.Component {
clientId: this.props.clientId,
discoveryDocs: this.props.discoveryDocs,
scope: this.props.scopes.join(' '),
fetch_basic_profile: this.props.profile,
redirect_uri: 'http://localhost:3000'
Copy link
Owner

Choose a reason for hiding this comment

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

If this.props.profile isn't set, what happens? redirect_uri should also be configurable by props

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

Successfully merging this pull request may close these issues.

2 participants