TUTORIAL Google Contacts to Asterisk Phonebook

Zento

New Member
Joined
May 27, 2015
Messages
4
Reaction score
0
Very nice, PhilRW!

Script working with a little modification needed by us, already published with pull request pending. :)
 
Joined
Feb 13, 2011
Messages
330
Reaction score
12
Hi Zento

Thanks for the answer but how to install that script in my Incredible PBX box ?


Grillo
 

Zento

New Member
Joined
May 27, 2015
Messages
4
Reaction score
0
Thanks for the answer but how to install that script in my Incredible PBX box ?
Grillo, that's not an easy answer... You should install Python, dependencies for the script, run it one time manually an create a cron job. Everything is done in console, not through web interface.
 

Hometech

Active Member
Joined
Mar 9, 2008
Messages
242
Reaction score
29
OK is there an updated install instructions? I just tried to get this installed from the first post in this thread then added PhilRW script ran it and I get

File "./googlecontacts.py", line 41, in <module>
from oauth2client import client
ImportError: No module named oauth2client

It would be nice if there was a new thread with all the instructions to get this going. Or if the first Post was updated with How to get this working with today's Date. It may also be great if Ward would do a Featured Piece on NerdVittles with the install instructions. Trying to piece this together is so frustrating!
 

dlemmink

New Member
Joined
Nov 9, 2013
Messages
2
Reaction score
0
Created JSON file.
Moved it into the running directory
Changed code to reflect name of JSON file.

I get this error:

Traceback (most recent call last):
File "./googlecontacts.py", line 230, in <module>
main()
File "./googlecontacts.py", line 129, in main
token = get_auth_token()
File "./googlecontacts.py", line 110, in get_auth_token
credentials = tools.run_flow(flow, storage, args)
File "build/bdist.linux-i686/egg/oauth2client/util.py", line 142, in positional_wrapper
File "build/bdist.linux-i686/egg/oauth2client/tools.py", line 180, in run_flow
UnboundLocalError: local variable 'success' referenced before assignment


Any ideas?
Running Asterisk 11 on FreePBX 12.0.76
 

lrosenman

Guru
Joined
Oct 17, 2014
Messages
221
Reaction score
30
I believe this is a bug in oauth2client 1.5.x. Try downgrading it to 1.4.12.
 

dlemmink

New Member
Joined
Nov 9, 2013
Messages
2
Reaction score
0
That did the trick. Downgrading to 1.4.12 eliminated the error.

How do I now keep the libraries from updating when I run updates?
 

MrCaseyJames

New Member
Joined
Oct 4, 2015
Messages
1
Reaction score
0
Hey guys, I made another way of doing this too. I could never get the oauth setup correctly so I made a method that uses a Google Script and a PHP script.

I detailed my process of my website here: Google Contacts to Asterisk Phonebook. Let me know what you guys think. Thanks.
 

lrosenman

Guru
Joined
Oct 17, 2014
Messages
221
Reaction score
30
I also have a set of scripts, using goobook as the means of getting the XML from google, and some shell/groovy/awk scripts to update the asterisk phonebook.

Let me know if anyone would like me to make them available.
 

piaftnt

Member
Joined
Jul 16, 2010
Messages
93
Reaction score
17
Does anyone know how to actually get this working again? I tried downloading https://github.com/PhilRW/gcontacts-asterisk but there does not seem to be any instructions on how to configure the thing. The README says to " Edit CLIENT_SECRETS_JSON in googlecontacts.py with the name of your client secrets file from Google Developers Console." but I have no idea how to actually get the client secrets file from Google Developers Console. My google foo is failing me. I would appreciate it if someone can point me in the right direction.

The system is a new ipbx 13-12-3 on Centos 6.7.
 

piaftnt

Member
Joined
Jul 16, 2010
Messages
93
Reaction score
17
I got it working. In case someone else wants to know how, below is what I did. Hope this helps.

  • login to the Google Developers Console at https://console.developers.google.com/
    • Create a new project.
    • Enable the "Contacts API"
    • In the new project, under "OAuth 2.0 client ID", click on the download icon to the right (next to client id)
    • save this file in the CWD
    • update CLIENT_SECRETS_JSON line in googlecontacts.py to use the file you just downloaded.
  • You will most likely need to install python-argparse and oauth2client modules.
    • On Centos-6 do yum install python-argparse
  • As far as I know oauth2client is not available as an rpm.
  • Do the following to install the oauth2client:
    • yum install python-pip (On Centos 6 the epel repo must be enabled to get python pip).
    • pip install oauth2client
  • Test the script with the following command ./googlecontacts.py --noauth_local_webserver
  • If you get a list of your contacts then run ./googlecontacts.py --asterisk --noauth_local_webserver to actually load your contacts into the asterisk phone book.
  • I have not figured out how to run this from cron because Google tokens have a short lifetime and must be renewed before you can access the contacts.
  • If someone else knows how to run this from cron please let me know.
 

Jordan

New Member
Joined
Feb 6, 2014
Messages
3
Reaction score
0
Hi piaftnt,

Thank you for your detailed step by step! It helped me out a lot and I was able to get this script up and running on my PBX (with a few minor modifications to suit my environment).

I have set my script up to run on my PBX once a day, and so far it seems that it takes care of itself in regards to the token. I have been testing over the last few days on my laptop, and after the initial authorisation steps to get access to my contacts, I have not had to do anything further - the script just runs with out a problem. I am guessing it has its own way of refreshing its token when needed (however I cannot find any evidence of this).

Anywho.. here is the line from my crontab file for this script:

0 0 * * * /root/google2asterisk/google2asterisk.py --add_type --delete --non_interactive --noauth_local_webserver --asterisk
 

Jordan

New Member
Joined
Feb 6, 2014
Messages
3
Reaction score
0
Just as a side note for anyone who runs into this problem, there are a couple of solutions.

During testing, I was running into an IO Error just after authorisation was granted. It seems that the script needs to write some information to a certificates file in the root file system. So a solution (for my PBX) was to have this script running under root - this is where asterisk is running from anyway so there are no issues writing to the phonebook from the script.

If your environment is not running as root then you need to make some permission changes on the certificate file that the script is trying to access. Depending on your environment and what version of httplib2 you have installed the path may vary. Please see bellow for the permissions command you need to run:

sudo chmod 644 /usr/local/lib/python2.7/dist-packages/httplib2-0.9.1-py2.7.egg/httplib2/cacerts.txt

This was found here: https://gitlab.com/goobook/goobook/issues/57

Hope this helps someone who is having the same issues I did.
 

Violator

New Member
Joined
Sep 15, 2016
Messages
1
Reaction score
0

JFrost

Active Member
Joined
Oct 1, 2016
Messages
351
Reaction score
93
Hey now.

I recognize this has been dormant for a while but I was wondering if this is still viable and if it could be used or adapted for use with IPBX Wazo (currently v17.13)
 

easydoor

New Member
Joined
Sep 30, 2018
Messages
1
Reaction score
0
Unbelivable how this thread is unorganised..
Everyone put/modified some script, and neither of them working today/nowday.
I found very elegant and simple workable solution, without python, just with google scripting + Google drive with schedule + php script what importing throught crond to Asterisk phonebook.
http://mrcaseyjames.com/?p=103
 

Members online

No members online now.

Forum statistics

Threads
25,781
Messages
167,507
Members
19,201
Latest member
troutpocket
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top