1

I have a PHP web application that uses OAuth2 to access and display the contents of users' Gmail inboxes. When the user is prompted for the first time to allow access, Google also then prompts him to select which Google account he'd like to grant access to. All users are in my Google Apps for Education domain with accounts named like "studentname@myschooldomain.com" and that's the only Gmail account I ever want to display in my web app. I don't want to give them the option of choosing a different Google account. Is there a way I can automatically select the correct Google account during the authorization process?

I've looked all over, and the closest answer I can find came from here. If I was using the Javascript library (which I'm not), I could pass authuser=0 to select the first Google account a user is logged into. Besides the fact that I'm not using JavaScript, the problem would be that I don't know if my domain's account is the first, second, or third Google account that a user is signed in to.

There must be a way to pass a user's Gmail address to automatically authorize that particular account. ...I hope!

Community
  • 1
  • 1
Kimber Warden
  • 151
  • 1
  • 14
  • I have to ask. Why? Why wouldn't they just use Gmail to view their mail? – Matt Apr 10 '17 at 21:10
  • There are lots of reasons why a developer would want to use the Google API. In my case, the users' Google account on my domain isn't their primary account...they probably have a personal account of their own. Therefore, they don't check their e-mail from my domain very frequently and I want them to know when they have a message without leaving my application. The Gmail API exists for this very reason. – Kimber Warden Apr 11 '17 at 18:33

0 Answers0