Comments (10)
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.
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.
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.
Hi @ScottAndrews888,
I have the same issue. Did you manage to get it work ?
from import-mailbox-to-gmail.
@yaaax, which of the errors are you getting?
from import-mailbox-to-gmail.
@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.
If you see "Client is unauthorized to retrieve access tokens using this method", it indicates one of the following things:
- The client ID (usually just a number) isn't authorized in your domain's Admin console.
- The client ID is authorized, but some or the scopes are missing or incorrect.
- 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.
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.
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.
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)
- Lots of 400 errors with no further details HOT 3
- Problem on Mac HOT 19
- Label Creation & Skipping Issue HOT 3
- Import Failed Messages? HOT 5
- import-mailbox-to-gmail.py: error: argument --dir is required HOT 12
- Attachments HOT 11
- Duplicate labels created when importing nested mboxes HOT 6
- oauth2client deprecated HOT 3
- os.walk error HOT 3
- No emails get imported HOT 4
- service = discovery.build error
- Add Dockerfile or instructions HOT 2
- Instructions are out of date or n/a HOT 1
- Issue when execute the commands HOT 1
- C
- Package 'rsa' requires a different Python: 2.7.18 not in '>=3.5, <4'
- How to show original sent date HOT 4
- Imports Duplicate Messages HOT 3
- NameError: name 'unicode' is not defined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from import-mailbox-to-gmail.