Title: Google API Error
Last modified: December 24, 2017

---

# Google API Error

 *  Resolved [grimecho](https://wordpress.org/support/users/grimecho/)
 * (@grimecho)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/google-api-error-4/)
 * I followed the directions for setting up SMTP mail sending via Google’s Gmail.
   I successfully created the Google API project, entered the correct information,
   and received a client ID and client secret. I pasted both of these into the WP
   Mail SMTP fields.
 * The only portion of setup that differed from what the guide said, was that when
   I pressed “Allow Plugin to send emails using your Google account” I was directed
   to a “This app isn’t verified. This app hasn’t been verified by Google yet. Only
   proceed if you know and trust the developer. ” warning. I selected Advanced –
   > “Go to echogy.net” and continued. Google successfully asked me for permission
   to allow echogy.net to send mail on my behalf. I pressed allow and was returned
   to the settings page for the plugin.
 * However, when trying to send a test email, I received the following:
 *     ```
       Versions:
       WordPress: 4.9.1
       WordPress MS: No
       PHP: 7.0.22-0ubuntu0.16.04.1
       WP Mail SMTP: 1.2.1
   
       Params:
       Mailer: gmail
       Constants: No
       Client ID/Secret: Yes
       Auth Code: Yes
       Access Token: No
   
       Server:
       OpenSSL: Yes
       PHP.allow_url_fopen: Yes
       PHP.stream_socket_client(): Yes
       PHP.fsockopen(): Yes
       PHP.curl_version(): Yes
       Apache.mod_security: No
   
       Debug:
       Error while sending via Gmail mailer: {
       "error": {
       "errors": [
       {
       "domain": "global",
       "reason": "required",
       "message": "Login Required",
       "locationType": "header",
       "location": "Authorization"
       }
       ],
       "code": 401,
       "message": "Login Required"
       }
       }
       ```
   
 * I repeated the procedure using a different Gmail account and has the exact same
   results.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgoogle-api-error-4%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Slava Abakumov](https://wordpress.org/support/users/slaffik/)
 * (@slaffik)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9810565)
 * After you confirmed to the Google, that you allow sending emails on your behalf,
   you should be redirected back to plugin admin area.
 * At this moment your site didn’t generate `Access Token`. You have `Auth Code`,
   provided by Google. Just reload the plugin page in admin area – the access token
   should be generated. You can do that also by sending Email Test one or several
   times.
 * I understand, that you wrote that you’ve already done that, but please do that
   again.
 *  [esarbege](https://wordpress.org/support/users/esarbege/)
 * (@esarbege)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9832492)
 * I, too, am having this problem, exactly as [@grimecho](https://wordpress.org/support/users/grimecho/),
   down to the warning and error message even though the API appears in the Gmail
   Search Console as having been verified 4 times.
 * I have reloaded the page in the admin area as [@slaffik](https://wordpress.org/support/users/slaffik/)
   suggested several times. I have also deleted the plug-in and reinstalled it.
 * Once I did all that, there is a change in the error message. Now it isn’t recognizing
   the Auth Code or Access Token and still, when hitting the confirm, I get the 
   warning and have to go through the “unsafe” allow on Google. Then, it redirects
   back to the plugin which indicates all is well until I try to send a test email.
 * Current error:
    Versions: WordPress: 4.9.1 WordPress MS: No PHP: 5.6.32 WP Mail
   SMTP: 1.2.2
 * Params:
    Mailer: gmail Constants: No Client ID/Secret: Yes Auth Code: No Access
   Token: No
 * Server:
    OpenSSL: Yes PHP.allow_url_fopen: Yes PHP.stream_socket_client(): Yes
   PHP.fsockopen(): Yes PHP.curl_version(): Yes
 * Debug:
    Error while sending via Gmail mailer: { “error”: { “errors”: [ { “domain”:“
   global”, “reason”: “required”, “message”: “Login Required”, “locationType”: “
   header”, “location”: “Authorization” } ], “code”: 401, “message”: “Login Required”}}
 * Any other ideas?
    -  This reply was modified 8 years, 3 months ago by [esarbege](https://wordpress.org/support/users/esarbege/).
      Reason: Additional info
 *  [reggie21](https://wordpress.org/support/users/reggie21/)
 * (@reggie21)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9836808)
 * I am having the exact same issue. I have recreated Client ID and Client secret
   twice and no luck. Still getting error messages:
 * There was a problem while sending a test email. Related debugging output is shown
   below:
 * Versions:
    WordPress: 4.9.1 WordPress MS: No PHP: 5.6.31 WP Mail SMTP: 1.2.2
 * Params:
    Mailer: gmail Constants: No Client ID/Secret: Yes Auth Code: No Access
   Token: No
 * Server:
    OpenSSL: Yes PHP.allow_url_fopen: Yes PHP.stream_socket_client(): Yes
   PHP.fsockopen(): Yes PHP.curl_version(): Yes
 * Debug:
    Error while sending via Gmail mailer: { “error”: { “errors”: [ { “domain”:“
   global”, “reason”: “required”, “message”: “Login Required”, “locationType”: “
   header”, “location”: “Authorization” } ], “code”: 401, “message”: “Login Required”}}
    -  This reply was modified 8 years, 3 months ago by [reggie21](https://wordpress.org/support/users/reggie21/).
 *  [esarbege](https://wordpress.org/support/users/esarbege/)
 * (@esarbege)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9840571)
 * I have been diligently working on this problem over the past couple of days and
   have learned some very important things:
 * First: Research now shows a two-pronged problem. My webhost is GoDaddy and GoDaddy
   blocks all outbound SMTP ports. Any plugin attempting to use any SMTP port will
   not work. I verified that directly with GoDaddy during a very long and intense
   tech help session today. So the WP Mail SMTP plug-in will never work on any GoDaddy
   website.
 * Second: My extensive testing over the past couple of days to various domains 
   indicated that my ISP is blocking all email from my webserver and in fact, from
   the GoDaddy range of IP addresses. The techs at GoDaddy traced the test emails
   from a different plug-in and confirmed that all emails from my site to my ISP
   were being blocked. So, the only recourse for me is to either:
    - Convince the blocking ISP to put an exception to the blocking for my server
      IP and/or email address or
    - Put a note on my site that anyone with an email address from that ISP will
      be unable to register for an account on the site. Please create a free account
      with Gmail, Hotmail or Yahoo first, then register for an account on the website.
 * Hope this info helps someone else.
 *  [gmatsushima](https://wordpress.org/support/users/gmatsushima/)
 * (@gmatsushima)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9857167)
 * why is this being marked as resolved?
 *  Thread Starter [grimecho](https://wordpress.org/support/users/grimecho/)
 * (@grimecho)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9857556)
 * I was the original poster and the issue was never resolved for me. I tried the
   suggested steps, but there was no change.
 * I ran the exact setup procedure multiple times and even tried it on a fresh WordPress
   install with no other plugins. I was never able to get passed the “Login Required”
   error. I ended up giving up and instead used a plan SMTP account to send out 
   mail.
 *  Plugin Author [Slava Abakumov](https://wordpress.org/support/users/slaffik/)
 * (@slaffik)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9858251)
 * [@grimecho](https://wordpress.org/support/users/grimecho/)
 * > I pressed allow and was returned to the settings page for the plugin.
 * I see that Auth Code is saved. So the issue is in getting Access Token.
    You 
   have used some Gmail email account to generate Client ID/Secret – is that the
   same as in your FROM email address field in plugin General settings? If not –
   try use the same email address (from Client ID/Secret). Make sure you do NOT 
   have “Allow…” button at the bottom of the page. IF you have – go through the “
   accepting” process again.
 *  [gmatsushima](https://wordpress.org/support/users/gmatsushima/)
 * (@gmatsushima)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9867382)
 * the above worked, thank you [@slaffik](https://wordpress.org/support/users/slaffik/)!
   It’s prompting a “Failed to send your message.” but I believe that may due to
   how I setup our contact form .. lmk if you have any insights to this as well,
   thanks again for your help .. this helped solve a very frustrating back-and-forth
   between to email/hosting vendors
 *  Plugin Author [Slava Abakumov](https://wordpress.org/support/users/slaffik/)
 * (@slaffik)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-9925124)
 * [@grimecho](https://wordpress.org/support/users/grimecho/)
 * Your issue might be fixed in 1.2.4. Please update and try to setup Gmail again.
   
   We previously wiped tokens needed to work on settings save, that it is fixed 
   in 1.2.4.
 *  [iampransh](https://wordpress.org/support/users/iampransh/)
 * (@iampransh)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/google-api-error-4/#post-10041605)
 * Using 1.2.5 version of plugin, still getting the same issue, test mail displays
   the same error as stated above
 * Also, when i authorise, it says you have successfully authorized the plugin to
   send email but when i send test email i get this error
    Any suggestions, need
   it on urgent basis
 *  [jpmelnik](https://wordpress.org/support/users/jpmelnik/)
 * (@jpmelnik)
 * [8 years ago](https://wordpress.org/support/topic/google-api-error-4/#post-10108528)
 * Same Here:
 * Using 1.2.5 version of plugin, still getting the same issue.
 *  [lunarwhale](https://wordpress.org/support/users/lunarwhale/)
 * (@lunarwhale)
 * [8 years ago](https://wordpress.org/support/topic/google-api-error-4/#post-10109847)
 * Still broken, why havent you guys fixed this yet?
 * There was a problem while sending a test email. Related debugging output is shown
   below:
 * Versions:
    WordPress: 4.9.4 WordPress MS: No PHP: 5.6.31 WP Mail SMTP: 1.2.5
 * Params:
    Mailer: gmail Constants: No Client ID/Secret: Yes Auth Code: Yes Access
   Token: No
 * Server:
    OpenSSL: Yes PHP.allow_url_fopen: Yes PHP.stream_socket_client(): Yes
   PHP.fsockopen(): Yes PHP.curl_version(): Yes Apache.mod_security: No
 * Debug:
    Error while sending via Gmail mailer: { “error”: { “errors”: [ { “domain”:“
   global”, “reason”: “required”, “message”: “Login Required”, “locationType”: “
   header”, “location”: “Authorization” } ], “code”: 401, “message”: “Login Required”}}
 *  [lunarwhale](https://wordpress.org/support/users/lunarwhale/)
 * (@lunarwhale)
 * [8 years ago](https://wordpress.org/support/topic/google-api-error-4/#post-10109987)
 * solution
 * I have tried this plugin and many others, and they all fail when making the smtp
   connection to gmail or outlook
 * As of PHP 5.6 you will get a warning/error if the SSL certificate on the server
   is not properly configured.
 * Gmail and Outlook use self signed certs so when php checks against the local 
   certificate authority bundle, the connection will fail
 * so in this case, the connection must be made bypassing the cert verification
 * Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ‘ssl’
   => array ( ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’
   => true, ),)
 * this allows the smtp connection to gmail
 * please add this option to your plugin, to avoid these errors in this support 
   thread
 *  [giakonda](https://wordpress.org/support/users/giakonda/)
 * (@giakonda)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-10235813)
 * I am updating site to add this plugin for client.
    Have got client ID and client
   secret and authorised redirect address.
 * Doesnt authorise.
 * Errorwhen trying to send test mail.
 * Versions:
    WordPress: 4.9.5 WordPress MS: No PHP: 5.6.12 WP Mail SMTP: 1.2.5
 * Params:
    Mailer: gmail Constants: No Client ID/Secret: Yes Auth Code: No Access
   Token: No
 * Server:
    OpenSSL: Yes PHP.allow_url_fopen: Yes PHP.stream_socket_client(): Yes
   PHP.fsockopen(): Yes PHP.curl_version(): Yes
 * Debug:
    Error while sending via Gmail mailer: { “error”: { “errors”: [ { “domain”:“
   global”, “reason”: “required”, “message”: “Login Required”, “locationType”: “
   header”, “location”: “Authorization” } ], “code”: 401, “message”: “Login Required”}}
 *  [Emir Mulalić](https://wordpress.org/support/users/ckskusa/)
 * (@ckskusa)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-10270853)
 * I am too having this problem:
 * Versions:
    WordPress: 4.9.5 WordPress MS: No PHP: 7.1.14 WP Mail SMTP: 1.2.5
 * Params:
    Mailer: gmail Constants: No Client ID/Secret: Yes Auth Code: Yes Access
   Token: No
 * Server:
    OpenSSL: Yes PHP.allow_url_fopen: Yes PHP.stream_socket_client(): Yes
   PHP.fsockopen(): Yes PHP.curl_version(): Yes Apache.mod_security: No
 * Debug:
    Error while sending via Gmail mailer: { “error”: { “errors”: [ { “domain”:“
   global”, “reason”: “required”, “message”: “Login Required”, “locationType”: “
   header”, “location”: “Authorization” } ], “code”: 401, “message”: “Login Required”}}

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Google API Error’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

## Tags

 * [gmail](https://wordpress.org/support/topic-tag/gmail/)

 * 15 replies
 * 10 participants
 * Last reply from: [Emir Mulalić](https://wordpress.org/support/users/ckskusa/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/google-api-error-4/#post-10270853)
 * Status: resolved