Resource icon

TUTORIAL IncrediblePBX GoogleVoice OAUTH

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
wardmundy submitted a new resource:

Incredible PBX Google Voice OAUTH - Use Incredible PBX credentials to set up OAUTH for your Google Voice trunks

A number of users have expressed concerns with using GVsip to host and store their OAUTH Refresh Tokens for Google Voice trunks. As a result, we have set up an alternate service that allows you to use our Google Client_ID and CLIENT_SECRET to privately manage your own OAUTH tokens. This tutorial will walk you through making the changes.

Before you begin, DELETE ALL OF YOUR GOOGLE VOICE TRUNKS using either the FreePBX GUI or the Incredible PBX GUI!

There are 3 Steps in Setting things up:...

Read more about this resource...
 

billsimon

Well-Known Member
Joined
Jan 2, 2011
Messages
1,534
Reaction score
727
The thing I have been wondering is whether Google is ultimately OK with the public distribution of a project's OAUTH2 client ID and secret. GVSIP did this by embeddeding the credentials within their Asterisk module source code and in your case here they are posted in the tutorial (but with one slightly better measure of security, that you have to log in to Xenforo to see them).

I wonder if Google has an API for the generation of developer projects.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Actually generated those with an account we NEVER use. Not sure how anyone could complain about your giving away your own credentials particularly when redirections are restricted to Google's OAUTH Playground.

* edited *
 

billsimon

Well-Known Member
Joined
Jan 2, 2011
Messages
1,534
Reaction score
727
No, of course it's not a serious concern. Just a musing.
 

sh0tsmash

New Member
Joined
Jul 8, 2014
Messages
15
Reaction score
0
Not working for me :-(. Running Centos w/ Asterisk 13. (http://nerdvittles.com/?p=14208) When I run 'amportal restart', asterisk takes a very long time, says there is an active call when there is not. After the 120 seconds it starts another timer and then stops. After reboot, it is not able to connect.

To go back, I just restore my image.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Asterisk 13 upgrade procedure has been tweaked. Original had problems on some platforms.
 

sh0tsmash

New Member
Joined
Jul 8, 2014
Messages
15
Reaction score
0
Asterisk 13 upgrade procedure has been tweaked. Original had problems on some platforms.


Updated directions work perfectly, thank you!

One thing I did change (that I do not think matters):

# in the menuselect module
# enable all Add-ons except app_mysql
# enable EXTRA-SOUNDS-EN-GSM in Extras Sound Packages
# then Save & ExitTpp_steam_mst_en_0907_1719
I also enabled a few other codecs (G729, Ulaw)
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Updated directions work perfectly, thank you!

One thing I did change (that I do not think matters):


I also enabled a few other codecs (G729, Ulaw)


Not required, but perfectly fine if you need them.
 

Jeff Messeroll

New Member
Joined
Oct 27, 2015
Messages
1
Reaction score
0
I am trying to get google voice working. I have followed the steps but I am receiving the following messages
Code:
2015-10-28 11:52:12] ERROR[2661]: res_xmpp.c:3661 xmpp_client_reconnect: No XMPP connection available when trying to connect client 'xxxxxxxxgmailcom' [2015-10-28 11:52:16] NOTICE[2661]: res_xmpp.c:3639 xmpp_client_reconnect: Connecting to client token : 1/4jzbnGG-pc_envGbBS3aZz17h-HtBO2wZQQZt8zatd0 [2015-10-28 11:52:16] NOTICE[2661]: res_xmpp.c:3877 fetch_access_token: Command CURL(https://www.googleapis.com/oauth2/v3/token,client_id=466295438629-prpknsovs0b8gjfcrs0sn04s9hgn8j3d.apps.googleusercontent.com&client_secret=4ewzJaCx275clcT4i4Hfxqo2&refresh_token=1/4jzbnGG-pc_envGbBS3aZz17h-HtBO2wZQQZt8zatd0&grant_type=refresh_token) [2015-10-28 11:52:16] NOTICE[2661]: res_xmpp.c:3881 fetch_access_token: Command status : { "access_token": "ya29.GgI_mGXa-9qjK1VpxUTvTxD4iCmweXE_oqMrKVgLr1lm0jzl039T-EFSwcO0iPi4GT0w", "token_type": "Bearer", "expires_in": 3600 } [2015-10-28 11:52:16] NOTICE[2661]: res_xmpp.c:3890 fetch_access_token: access Token : ya29.GgI_mGXa-9qjK1VpxUTvTxD4iCmweXE_oqMrKVgLr1lm0jzl039T-EFSwcO0iPi4GT0w
So it looks like the token is working but the XMPP is not? Thanks Jeff
 

Kinjo

New Member
Joined
Dec 1, 2015
Messages
10
Reaction score
3
I'm wondering if someone can lead me in the right direction in order to troubleshoot a potential race condition that is happening on an IncrediblePBX bare metal atom processor platform that is not happening on my non-dedicated but faster virtualbox platform.

It's only since enabling OAUTH support and associating two GV accounts to it; that after a reboot Asterisk doesn't load properly which then results in FreePBX failing to connect to the Asterisk Manager.

Code:
[2015-12-15 22:35:46] ERROR[2255] astobj2.c: Invalid refcount -1 on ao2 object 0xa97ae64
[2015-12-15 22:36:45] VERBOSE[2258] asterisk.c: Remote UNIX connection
[2015-12-15 22:36:45] VERBOSE[2835] asterisk.c: Remote UNIX connection disconnected
[2015-12-15 22:38:46] VERBOSE[2258] asterisk.c: Remote UNIX connection
[2015-12-15 22:38:46] VERBOSE[3219] asterisk.c: Ignoring asterisk shutdown request, already in progress.
[2015-12-15 22:38:46] VERBOSE[3219] asterisk.c: Remote UNIX connection disconnected
[2015-12-15 22:38:46] VERBOSE[2258] asterisk.c: Remote UNIX connection
[2015-12-15 22:38:46] VERBOSE[3222] asterisk.c: Remote UNIX connection disconnected

I'm using the latest IncrediblePBX13.2.iso as the base on both platforms and they have identical configurations.

Different ways that mitigate the problem:
Waiting a couple of minutes after boot to issue an amportal restart and amportal a r
Removing one or both GV accounts from motif - just reducing it to one account fixes the potential race condition and the system loads as expected.
Installing the Lean edition via the IncrediblePBX13.2.iso base seems to work well. Although I am sure it is just a cosmetic problem since it works fine, the post shell login menu shows the GV OAUTH as being down.

Any insight into this will be helpful - Thank you!

Edit 2015.12.15 - Updating mitigation results based on installing the Lean version.
 
Last edited:

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Wish I had an answer for you, @Kinjo. What I can tell you is we have multiple servers running with multiple Google Voice trunks + OAUTH and we're not seeing the problem. You didn't mention your platform. Could it be an out of memory issue? If not, I think I'd start by reinstalling Asterisk and then loading the patch again. Be sure to remove your GV trunks before you begin!
 

Kinjo

New Member
Joined
Dec 1, 2015
Messages
10
Reaction score
3
@ward it honors me that you took a peek at this. Prior to installing the Lean and Mean, I rebuilt the Full Enchilada from scratch as well as just rebuilding Asterisk. The only way I could get it working after a reboot on the Full Enchilada (with both GV trunks) was to restart amportal - then all was happy again.

I think the timing of your latest post is a sign for me to upgrade... Those Intel NUCs look perfect! :)

This is what I was working with:
OEM production - 2550L2D-MxPC
Intel Atom D2550 dual core 1.86GHz
4G DDR3-1066
60Gig SSD SATA3
 
Last edited:

Kinjo

New Member
Joined
Dec 1, 2015
Messages
10
Reaction score
3
@wardmundy I was able to recreate the problem on the new hardware and virtual platforms. It appears to be a condition during startup on platforms with multiple cores running Full Enchilada - when there are two GV accounts with OATH support (allocating 2 - 8G of memory did not have any positive or negative impact).

Quad Core - 2GV - amportal commands appear to be issued multiple times during startup. The last one fails to stop Asterisk gracefully and after the 120 second timer it forces it to stop. Asterisk never starts and creates a fatal condition when trying to connect to the Asterisk Manager.
Dual Core - 2GV - Same as above
Dual Core - 1GV - amportal commands appear to be issued multiple times during startup. The last one is able to stop Asterisk gracefully and continues to boot normally.
Single Core - 2GV - amportal commands appear to be issued multiple times during startup. The last one fails to stop Asterisk gracefully and after the 120 second timer it forces it to stop. Asterisk starts back up and continues to load normally from that point.

I've confirmed this impacts platforms running:
- IncrediblePBX13.2 SL base / Full Enchilada
- CentOS 6.7 base / Full Enchilada via incrediblepbx13-12.2-centos

I've confirmed this does not impact platforms running:
- IncrediblePBX13.2 SL base / Lean and Mean

I've recorded the VM consoles on boot of the different environments - if you are interested in the output I gathered.

It would seem if there was a way to relax the timing or consolidate the amportal commands issued on a Full Enchilada w/ GV OATH platform during startup - that this may be fixed!
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Edit /etc/rc.local and remove duplicates. Change amportal restart to separate commands: amportal kill and amportal start. See if that fixes it and let us know.
 

Kinjo

New Member
Joined
Dec 1, 2015
Messages
10
Reaction score
3
Unfortunately I was not able to find any existing amportal commands in rc.local:

Code:
root@pbx36:~ $ cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
sleep 5
/usr/local/sbin/gui-fix
sleep 5
/usr/local/sbin/iptables-restart
exit 0
WARNING: Always run Incredible PBX behind a secure hardware-based firewall. 
root@pbx36:~ $

I also checked in all the rc's just in case - with no luck:

Code:
root@pbx36:~ $ grep -R amportal /etc/rc*
WARNING: Always run Incredible PBX behind a secure hardware-based firewall. 
root@pbx36:~ $
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Try making the amportal changes in /usr/local/sbin/iptables-restart
 

Kinjo

New Member
Joined
Dec 1, 2015
Messages
10
Reaction score
3
Ward you are the man! ...but of course you already knew that. :batman:

TL;DR - By removing the amportal restart found in gui-fix and separating it into amportal kill and amportal start, that fixed the issue. It would appear Asterisk wasn't running when the reset was being issued, creating the timeout/fatal condition.

So here is the play by play for those interested in seeing what happened:

As noted by Ward, the source of the startup problem was in the /etc/rc.local although it didn't issue any amportal commands directly it did reference the two scripts, gui-fix and iptables-restart as noted above.

So by grepping each I found the aportals were happening in the gui-fix script:
Code:
root@pbx36:~ $ grep amportal /usr/local/sbin/iptables-restart

root@pbx36:~ $
root@pbx36:~ $ grep amportal /usr/local/sbin/gui-fix
/usr/local/sbin/amportal chown
/usr/local/sbin/amportal a ma refreshsignatures
/usr/local/sbin/amportal a reload
/usr/local/sbin/amportal restart
/usr/local/sbin/amportal a r
root@pbx36:~ $

The amportal restart was the one causing the problem so I wanted to make a backup and I created a version I could mess around with:
Code:
root@pbx36:~ $ cp /usr/local/sbin/gui-fix /usr/local/sbin/gui-fix.org
root@pbx36:~ $ cp /usr/local/sbin/gui-fix /usr/local/sbin/gui-fix.mod
root@pbx36:~ $ nano /usr/local/sbin/gui-fix.mod
root@pbx36:~ $
root@pbx36:~ $ cp /usr/local/sbin/gui-fix.mod /usr/local/sbin/gui-fix
cp: cannot remove `/usr/local/sbin/gui-fix': Operation not permitted
root@pbx36:~ $

Since I wasn't permitted to alter gui-fix, that prompted me to confirm the attributes:
Code:
root@pbx36:~ $ cd /usr/local/sbin
root@pbx36:/usr/local/sbin $ lsattr
-------------e- ./amportal
-------------e- ./gui-fix.org
----i--------e- ./gui-fix
-------------e- ./amportal.bak
-------------e- ./sendmailmp3
-------------e- ./gui-fix.mod
-------------e- ./status
-------------e- ./mime-construct
-------------e- ./iptables-restart
root@pbx36:/usr/local/sbin $

Since the gui-fix had the immutable flag set; I needed to remove it to continue:
Code:
root@pbx36:/usr/local/sbin $ chattr -i gui-fix
root@pbx36:/usr/local/sbin $ cp /usr/local/sbin/gui-fix.mod /usr/local/sbin/gui-fix
root@pbx36:/usr/local/sbin $ chattr +i gui-fix

Ward thank you again for your patience and helping me out with this... Merry Christmas!
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
Thank you for the discovery. We'll make the change. For the record, on most systems, this should never be a problem.
 

Members online

Forum statistics

Threads
25,778
Messages
167,504
Members
19,198
Latest member
serhii
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