-
Notifications
You must be signed in to change notification settings - Fork 143
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
Custom scopes for different requirements (Android and iOS) #269
Conversation
…itialize function for users to add scopes on the fly
interesting But it needs some fine-tuning. |
Just to add on, I am using this code in production and have no problems with it so far Do let me know what can be improved on the code whether on readability or others. Would like to learn from it |
please, add example how to use |
we just need to reuse the same code example in the readme.md for web Example: import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
// use hook after platform dom ready
GoogleAuth.initialize({
clientId: 'CLIENT_ID.apps.googleusercontent.com',
scopes: ['profile', 'email'],
grantOfflineAccess: true,
}); The parameters will be passed to the iOS or Android handlers automatically. So essentially there is no code change for the end user for this to work |
I still think your idea is great, I also think you should remove the
and add an example of how to use it dynamically. @AlvinTCH could you help with that? |
synced changes
For the Sorry I can't see which part that needs explanation due to my own blindsight as it is written by myself. Can you let me know which part of the explanation is not clear on how to use it dynamically? |
hi @AlvinTCH let's fix the conflicts then, and I'll do the merge for the next major release |
Ok sure. Let me get to it when I get back tonight |
@reslear it is done |
by the way I have created an npm package with this particular implementation and have been using it for over a year |
sounds cool, and you're not using capacitor.config now? P.s. I plan to merge the changes into this major release |
Thats a really fast reply. I am still putting the standard values at capacitor.config as a fallback |
Having custom scopes whenever the function initializes
I have an app whereby there are different scope requirements for different functions of the app so as to not request excessive scopes from the user.
For example,
['email', 'profile']
is sufficient.['email', 'profile', 'https://www.googleapis.com/auth/calendar']
There is currently no convenient way to do this in the app as it takes the scope from the capacitor config (i.e capacitor.config.json)
So in this implementation, I am taking the data from the
GoogleAuth.initialize
function for reusabilityIn the component that requires login, initialize GoogleAuth with the appropriate parameters they need
The general idea for this implementation:
loadSignInClient
)initialize
function, get the custom params from the call (GoogleAuth.initialize
), with the data from capacitor.config.json as the fallbackloadSignInClient
and use these applicable parameters to initialize the Google Signin ClientTesting
Currently, I have tested this implementation with my app to ensure that it only queries the applicable scope for the different features in my app. If required, I am considering creating an NPM package for my fork as I kind of need this feature urgently, and anyone who needs this implementation can use that package to test before this pull request is merged in.
Note