Gmail API - Wrong exception fired when user's Gmail account is disabled - gmail-api

I'm working on a C# project that use Gmail API in single-user mode to retrieve user's mail. The application is working nicely.
Recently, we got a strange behavior from this API. When the user hasn't a #gmail account with Gmail disabled and try to use our product, for some we got a "Bad Request 400" with "Mail service not enabled" exception and for other users, we got "Bad Request 400" with "failedPrecondition" exception.
The users are on the same domain name. I searched through Gmail API documentation and I found nothing that can explain this.
Our thoughts are that maybe some users have different settings in their Google account that can cause the "general" "failedPrecondition".
Any advice?
Thanks

Related

How to check other user availability with Microsoft Graph API?

I'm trying to implement checking availability for specific user (actually a room) in O365 calendar. I'm using Graph API as it's recommended by Microsoft.
My first approach was using POST on https://graph.microsoft.com/v1.0/me/findMeetingTimes with the message body prepared according to template given in Graph API Explorer. On the API Explorer everything seems to work fine but when I try to run exactly the same request with my applications token I receive 403:
{
"error": {
"code": "ErrorAccessDenied",
"message": "Access is denied. Check credentials and try again.",
"innerError": {
"request-id": "b130177d-e138-4cc7-8e72-5d3529a9dc24",
"date": "2017-03-21T08:47:10"
}
}
}
I checked the app's delegated permissions in AAD and they seem to be fine. For Microsoft Graph those are granted:
Calendars.ReadWrite.Shared
Calendars.Read.Shared
Calendars.ReadWrite
Calendars.Read
I get exactly the same response (403) when I try to simply list user's events: https://graph.microsoft.com/v1.0/users//events In Graph API Explorer 500 is returned.
I found the following bug description: https://github.com/microsoftgraph/microsoft-graph-docs/issues/559 (and probably this one too) Is it related with the issues above?
Any clue what I might be doing wrong?
Is there any other way to achieve the same using different endpoint or API assuming that I still want to use oAuth for authorization?
I will be grateful for any hint
Update: Outlook Calendar API seems to work. Still appreciate any ideas why Graph API doesn't?
The FindMeetingAPI needs A work or a school account . If you are logging in using your personal email ID , you might not be able to login. Moreover , you need to set permissions to Calendars.Read Calendars.Read.All Calendars.ReadWrite User.Read"

Gmail - get mailbox delegations in latest API

I am attempting to get a list of mail delegates for each user within a domain on gmail to display to our users at www.rulerr.com . I am authenticating as a service account with domain wide delegation. I pull a list of users, and then authenticate using the service account as each user in the domain to access their gmail data.
Unfortunately it looks like I cannot access delegation information with the latest API, but the functionality exists in the old (now deprecated) API. When will this functionality be moved to the latest API? Or is there a different endpoint that I should be using?
I have also attempted to work around this by delegating user B's gmail to user A, authenticating as user A and then attempting to list messages within user B's mailbox which results in an error:
{ [Error: Delegation denied for <email redacted>]
code: 403,
errors:
[ { domain: 'global',
reason: 'forbidden',
message: 'Delegation denied for <email redacted>' } ] }
Thanks for your help.
As of now we will just have to wait for the Gmail API to add the delegation feature from the deprecated Email Settings API:
Managing delegation
settings
Delegation settings are not yet available via the API.
Disclaimer: I work on Gmail and the Gmail API platform.
Managing Delegation Settings
We're happy to announce that we have now released the new Gmail API delegate settings methods, effectively replacing the long since deprecated Email Settings API delegation settings methods.
You can now use the standard libraries and tools found at https://developers.google.com/gmail/api to interact with the new Gmail delegate settings methods.
We will be publishing a blog post at https://gsuite-developers.googleblog.com raising the visibility of the new delegate settings methods in the coming weeks, but I wanted to personally give you a courtesy heads-up.
Documentation
Overview/introduction guide:
https://developers.google.com/gmail/api/guides/delegate_settings
Reference documentation: https://developers.google.com/gmail/api/v1/reference/users/settings/delegates
Migration guide (from the deprecated Email Settings API delegation settings methods):
https://developers.google.com/gmail/api/guides/migrate-from-email-settings#managing_delegation_settings

outlook restapi does not load calendars events for outllok personal account

I have been using outlook rest api's to read/create/update calendar events of outlook account.
Followed all the steps https://dev.outlook.com/RestGettingStarted/
It works very well for the subscription account's.
But the api does not work to load the calendar events of my personal outlook account ex: phani.xxx#outlook.com.
API responds with below error:
"error": {
"code": "ErrorMissingEmailAddress",
"message": "When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids."
}
I have tried the same with outlook sandbox got the same response.
Any help on this to get this api working for any outlook account. Will be highly appreciated.
This is likely due to your account not yet being enabled for the REST API. There's an issue with the v2 endpoint not returning the proper error message in this case.

Mail GAE not sending but

I have a problem sending mail with JavaMail Service in GAE.
I did all the code in the documentation, i debug it online and it work fine, and it count the mail sended in the quota section the problem is, i didn't receive anything, and also checked with the account sender and it's the same there isn't any trace of mail sended. I tried this for some mails address and it's not working too.
Anyone had this problem yet? A solution to this?
The problem is that the mail sended as SPAM on gmail account.
Read doc: https://cloud.google.com/appengine/docs/java/mail/#Java_Authenticating_mail_DKIM
The email used to send the mails must be a member of the application. It can be the problem... It was with me.
https://cloud.google.com/appengine/docs/python/mail/
The link is about python but for sure that the same email rules apply to Java.
For security purposes, the sender address of a message must be one of the >following:
The Gmail or Google Apps Account of the user who is currently signed in
Any email address of the form anything#appname.appspotmail.com or >anything#appalias.appspotmail.com
Any email address listed in Email API Authorized Senders found in the App >Engine Settings page of the Developers Console

Error: invalid_client with Google Apps API OAuth2

I am using Google Apps API for my application with OAuth2. ,but I get an error.
Error: invalid_client
no support email
Request Details
That’s all we know.
If you create OAuth credentials BEFORE you set the support email address in the consent screen, then it appears that you will always get this error, even after setting the support email.
I resolved this by setting the support email, and then recreating all necessary OAuth ids in the credentials page.
In the Google Developer console make sure that you have added a product name and an email address under. Apps & auths -> consent screen.
Update: This shouldn't be to much of a problem anymore. Google made a change in the console that wont let you save anything until you have updated these items.
In Google Developer Console turn Gmail API on.
GDC > Dashboard > Use Google APIs > Google Apps APIs > Gmail API
Be sure that you are set up the setDeveloperKey with your EMAIL ADDRESS offred in Google Console whe you create a Client ID for web application.
Had the same problem and the solution was:
Set my email
Recreate the keys
Activate Google API+ from API Library
1) Fill out the info email address and produce name as well as other details in the 'consent' screen on google's console when you generate the keys.
2) And make sure when you copy paste the ClientID and ClientSecret code from google to your workspace (IDE), there might be some unwanted spaces inbetween
Check with the google console and remove it.
Hope this helps,
--happy coding!

Resources