Git Product home page Git Product logo

Comments (10)

eesheesh avatar eesheesh commented on April 27, 2024

Hi,

This usually happens if you use the wrong JSON file. It should start with "type": "service_account", if it doesn't, then make sure you download the key JSON file from the "Service accounts" section, and not the "OAuth 2.0 client IDs" section.

from import-mailbox-to-gmail.

ScottAndrews888 avatar ScottAndrews888 commented on April 27, 2024

Thank you for the advice. I tried to create a new service account and downloaded both versions of the json file. Both are having the same errors when processing. Note that the downloaded name of the json file did not have an _ between "Gmail" and "API...". I added the underscore between Gmail and API because the file name was not recognized with a space. Perhaps this is causing a problem? The following is the response I am receiving. Please let me know if you see what else I am doing wrong that needs to be corrected. Thank you for your help.

C:\Users\Sandrews>C:\Python27\import-mailbox-to-gmail.py --json C:\Users\Sandrews\Downloads\Gmail-API-ad776fdXXXXX.json --dir C:\mbox
14:50:16 INFO [email protected] *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] ***
14:50:16 INFO [email protected] Arguments:
14:50:16 INFO [email protected] auth_host_name: 'localhost'
14:50:16 INFO [email protected] auth_host_port: [8080, 8090]
14:50:16 INFO [email protected] dir: 'C:\mbox'
14:50:16 INFO [email protected] fix_msgid: True
14:50:16 INFO [email protected] httplib2debuglevel: 0
14:50:16 INFO [email protected] json: 'C:\Users\Sandrews\Downloads\Gmail-API-ad776fdXXXXX.json'
14:50:16 INFO [email protected] log: 'import-mailbox-to-gmail-10764.log'
14:50:16 INFO [email protected] logging_level: 'INFO'
14:50:16 INFO [email protected] noauth_local_webserver: False
14:50:16 INFO [email protected] num_retries: 10
14:50:16 INFO [email protected] replace_quoted_printable: True
14:50:16 INFO [email protected] Processing user [email protected]
14:50:16 WARNING autodetect@init.py file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\googleapiclient\discovery_cache_init_.py", line 41, in autodetect
from . import file_cache
File "C:\Python27\lib\site-packages\googleapiclient\discovery_cache\file_cache.py", line 41, in
'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0
14:50:16 INFO [email protected] URL being requested: GET https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest
14:50:16 INFO [email protected] Attempting refresh to obtain initial access_token
14:50:17 INFO [email protected] Refreshing access_token
14:50:18 INFO [email protected] Failed to retrieve access token: {
"error" : "unauthorized_client",
"error_description" : "Client is unauthorized to retrieve access tokens using this method."
}
14:50:18 ERROR [email protected] Can't get access token for user [email protected]
14:50:18 ERROR [email protected] Can't process user [email protected]
Traceback (most recent call last):
File "C:\Python27\import-mailbox-to-gmail.py", line 307, in main
service = discovery.build('gmail', 'v1', http=http)
File "C:\Python27\lib\site-packages\oauth2client_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python27\lib\site-packages\googleapiclient\discovery.py", line 228, in build
requested_url, discovery_http, cache_discovery, cache)
File "C:\Python27\lib\site-packages\googleapiclient\discovery.py", line 275, in _retrieve_discovery_doc
resp, content = http.request(actual_url)
File "C:\Python27\lib\site-packages\oauth2client\transport.py", line 159, in new_request
credentials._refresh(orig_request_method)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 744, in _refresh
self._do_refresh_request(http)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 812, in _do_refresh_request
raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
HttpAccessTokenRefreshError: unauthorized_client: Client is unauthorized to retrieve access tokens using this method.
14:50:18 INFO [email protected] *** Done importing all users from directory 'C:\mbox'
14:50:18 INFO [email protected] *** Import summary:
14:50:18 INFO [email protected] 0 users imported with no failures
14:50:18 INFO [email protected] 0 users imported with some failures
14:50:18 INFO [email protected] 1 users failed
14:50:18 INFO [email protected] 0 labels (mbox files) imported with no failures
14:50:18 INFO [email protected] 0 labels (mbox files) imported with some failures
14:50:18 INFO [email protected] 0 labels (mbox files) failed
14:50:18 INFO [email protected] 0 messages imported successfully
14:50:18 INFO [email protected] 0 messages failed

14:50:18 INFO [email protected] *** Check log file import-mailbox-to-gmail-10764.log for detailed errors.
14:50:18 INFO [email protected] Finished.

from import-mailbox-to-gmail.

eesheesh avatar eesheesh commented on April 27, 2024

The good news is that error means that you are using the correct JSON file. :)

The error message unauthorized_client: Client is unauthorized to retrieve access tokens using this method. means that the scopes weren't correctly authorized in the Admin console of the G Suite domain (steps 16+ on https://github.com/google/import-mailbox-to-gmail).

Even if you authorized it correctly, it could take a while (usually less than an hour) for the permissions to apply.

from import-mailbox-to-gmail.

yaaax avatar yaaax commented on April 27, 2024

Hi @ScottAndrews888,
I have the same issue. Did you manage to get it work ?

from import-mailbox-to-gmail.

eesheesh avatar eesheesh commented on April 27, 2024

@yaaax, which of the errors are you getting?

from import-mailbox-to-gmail.

yaaax avatar yaaax commented on April 27, 2024

@eesheesh I get the same response "Client is unauthorized to retrieve access tokens using this method."

2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:286) *** Starting import-mailbox-to-gmail 1.3 on Python 2.7.13 (default, Dec 17 2016, 23:03:43) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] ***
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:287) Arguments:
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	auth_host_name: 'localhost'
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	auth_host_port: [8080, 8090]
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	dir: './'
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	fix_msgid: True
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	httplib2debuglevel: 0
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	json: 'Gmail API-2f4282a7c0c4.json'
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	log: 'import-mailbox-to-gmail-17518.log'
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	logging_level: 'INFO'
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	noauth_local_webserver: False
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	num_retries: 10
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:289) 	replace_quoted_printable: True
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:302) Processing user [email protected]
2017-03-12T16:36:01 (+0100) 17518 WARNING autodetect (__init__.py:44) file_cache is unavailable when using oauth2client >= 4.0.0
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 41, in autodetect
    from . import file_cache
  File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
    'file_cache is unavailable when using oauth2client >= 4.0.0')
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0
2017-03-12T16:36:01 (+0100) 17518 INFO _retrieve_discovery_doc (discovery.py:273) URL being requested: GET https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest
2017-03-12T16:36:01 (+0100) 17518 INFO new_request (transport.py:157) Attempting refresh to obtain initial access_token
2017-03-12T16:36:01 (+0100) 17518 INFO _do_refresh_request (client.py:772) Refreshing access_token
2017-03-12T16:36:01 (+0100) 17518 INFO _do_refresh_request (client.py:799) Failed to retrieve access token: {
  "error" : "unauthorized_client",
  "error_description" : "Client is unauthorized to retrieve access tokens using this method."
}
2017-03-12T16:36:01 (+0100) 17518 ERROR main (import-mailbox-to-gmail.py:310) Can't get access token for user [email protected]
2017-03-12T16:36:01 (+0100) 17518 ERROR main (import-mailbox-to-gmail.py:348) Can't process user [email protected]
Traceback (most recent call last):
  File "./import-mailbox-to-gmail.py", line 308, in main
    service = discovery.build('gmail', 'v1', http=http)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 228, in build
    requested_url, discovery_http, cache_discovery, cache)
  File "/usr/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 275, in _retrieve_discovery_doc
    resp, content = http.request(actual_url)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/transport.py", line 159, in new_request
    credentials._refresh(orig_request_method)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 744, in _refresh
    self._do_refresh_request(http)
  File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 812, in _do_refresh_request
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
HttpAccessTokenRefreshError: unauthorized_client: Client is unauthorized to retrieve access tokens using this method.
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:349) *** Done importing all users from directory './'
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:350) *** Import summary:
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:352)     0 users imported with no failures
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:354)     0 users imported with some failures
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:356)     1 users failed
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:358)     0 labels (mbox files) imported with no failures
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:360)     0 labels (mbox files) imported with some failures
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:362)     0 labels (mbox files) failed
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:364)     0 messages imported successfully
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:366)     0 messages failed

2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:369) *** Check log file import-mailbox-to-gmail-17518.log for detailed errors.
2017-03-12T16:36:01 (+0100) 17518 INFO main (import-mailbox-to-gmail.py:370) Finished.

from import-mailbox-to-gmail.

eesheesh avatar eesheesh commented on April 27, 2024

If you see "Client is unauthorized to retrieve access tokens using this method", it indicates one of the following things:

  1. The client ID (usually just a number) isn't authorized in your domain's Admin console.
  2. The client ID is authorized, but some or the scopes are missing or incorrect.
  3. The client ID is authorized with the correct scopes, but not enough time has passed (like I said, usually it's less than an hour).

Please verify that you followed steps 16 and on from https://github.com/google/import-mailbox-to-gmail, and that you copied the Client ID field correctly. I'm asking about this because a common mistake is to enter something else instead of the client ID, like the service account name, or the service account email address.

Thanks!

from import-mailbox-to-gmail.

yaaax avatar yaaax commented on April 27, 2024

Thanks @eesheesh for your reply.
I finally found the solution here
The response from Bryan:

The .mbox file you're looking for to import is inside the "xxxx.mbox" directory created by your Apple Mail export.

from import-mailbox-to-gmail.

eesheesh avatar eesheesh commented on April 27, 2024

Thanks for the update! I'll close this now, based on your report. If you encounter any errors, please update this issue or create a new one, as needed.

from import-mailbox-to-gmail.

jonathan-golorry avatar jonathan-golorry commented on April 27, 2024

Please verify... you copied the Client ID field correctly. I'm asking about this because a common mistake is to enter something else instead of the client ID, like the service account name, or the service account email address.

I'm leaving this comment because I've noticed that when you enter the service account email address, the console actually correctly identifies the Client ID and displays that as the client name. Don't let that trick you into actually thinking it worked, though. You need to actually enter the Client ID yourself.

from import-mailbox-to-gmail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.