I need to download Gmail emails using php api. there APIs for google. i do not exactly which api to use. i have web application. i have registered my application on google, oauth2.0. at this url Google Api console. i have downloaded this php API
I which there are many services. but not gmail. I do not want to use accessing emails using username and password API. i want to access using the token. which is permanent access token.
Google support OAuth authentication for IMAP. Use that.
Related
I have to use my google account for gmail and drive services.
For drive services now i am using an service account but i cant find any possibility for send emails by service account.
Can i login to my account by google api php only using code?
I have registered in db my token && refresh_token, in any moment i could use it.
Gmail api does support service accounts, the only issue is that it only works with google workspace gmail accounts, you need to set up domain wide delegation on a workspace account to allow the service account to delignate as a user on the domain.
If you are only accessing your own account you can use Oauth2 and just store the refresh token, your app can just continue to use that to request a new access token whenever it needs.
Another option would be to go though the Gmail smtp server instead, using an apps password.
I've been using a PHP script to access Google's SMTP and IMAP so that emails sent from the script page are copied to the client's Gmail sent items. However Google has now locked down and locked out "insecure apps" which also seems to lock out my script, no matter which settings I change in Gsuite or the gmail account. How would I make it a "secure app" given that the usual app password approach seems inapplicable, since the device is a web server?
Securing your App would consist on using the more secure OAuth2 protocol to make requests to the Gmail API or authenticate to the SMTP or IMAP.
Using the Gmail API is more user friendly and for your use case I think it's more indicated. You can start building a Gmail App using these tutorials.
Read these articles to know more about OAuth on Gmail Apps:
IMAP/SMTP
Google APIs
I receive confirmation from users in my gmail account. I want to read them with a server side php script to display confirmation on my website. I got OAuth 2.0 client IDs and a service key from Google APis. How do I use these keys with the specific gmail account to get the emails? I cannot find any simple documentation.
You can not use a service account to access a normal users Gmail account. This is because there is no way to preauthorize it.
What you need to do is have the users authenticate your application using Oauth2 and get a refresh token for each user. Then you will be able to use the refresh token in your server sided script to request a new access token which you can use to read there gmails. The Google PHP client library team has created some examples for using their library which might help you. Google-api-php-client
Side note: If the users you are speaking of are part of a Google domains account then you can do it by giving service account permissions to access the users emails.
Trying to create a function that manages Google Calendar items via PHP for a Google Apps account. Cannot use web client OAuth, all authentication must be server to server.
I did the following in the Google Apps admin panel:
Enabled API access for the domain.
Created the OAuth key and secret for the domain.
Searched through many tutorials and cannot find anything related to Google Apps, and using the domain oauth key to retrieve user data. All of the examples either require a Service Account or Client OAuth (which is not an option).
Any ideas where to start?
i need to fetch users inbox using google oauth2.0 protocol api. i have downloaded this api.
i have downloaded this API
http://code.google.com/p/google-api-php-client/downloads/list.
This pai has many services but i did not find any way to grab user gmail inbox. i have got access_token using oauth 2.0.
Please some suggestion about this problem.