-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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", |
There was a problem hiding this comment.
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 })) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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
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