-
Notifications
You must be signed in to change notification settings - Fork 134
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
Multiple user login not working #270
Comments
Your code sample is not going to work the way you expected. In order for it to work, you have to save the userID somewhere else, which was generated randomly so that you can retrieve this ID later on (for further requests such as list mails, read mails, etc.) The package was created to allow multiple credentials; however, quite in a different manner - it supposed that the application that uses the package has multiple users, and thus, it saves the Google API responses in JSON files according to the ID of the currently logged-in user (or whichever other user in that system). That is logically understandable. However, it left out some edge cases:
The package itself does not acquire any userID from Google response, at least not before executing makeToken(). It is not impossible to modify the sample codes to get the information you need (whatever is necessary to feed the $userID), but I don't want to make things complicated. The quick dirty "workaround" code is as follows:
inside callback() method, you only need to use the basic sample code provided:
The code will save response data to a JSON file with a logged-in email address. For eg.; instead of saving to gmail-json-1.json, gmail-json-2.json..., it will save to gmail-json-someone@gmail.com.json; Later on, when calling further methods, you only need to specify the logged in email address as userID, then you are all set. By pointing out some edge cases above, I also proposed that it is necessary to change the code to archive "true" multiple credentials by using it. Developers will not have to update the package manually for such "tweaks". This is not the perfect solution, it is just the quickest one, because it still leaves the second edge case listed above. For system with multiple users, the correct way to save response filename should be: |
@gnucasher Thanks for your reply |
Hi @kstmostofa, I'm glad to hear that you've resolved your issue with a different approach! I'm always interested in learning new solutions. Would you mind sharing the details of your approach? I'd love to know more about how you tackled the problem. Thanks, |
I am using
setUserId
to set the token but somehow login is not working.below are my code sample
public function callback() { $userId = 'user'. rand(1, 100); LaravelGmail::setUserId($userId)->makeToken(); return redirect()->to('/'); }
Thanks in advance
The text was updated successfully, but these errors were encountered: