Quantcast
Channel: VOIP Tech Chat forum - dslreports.com
Viewing all articles
Browse latest Browse all 6358

GVSIP configuration helper for FreePBX users

$
0
0
This is a very simple script to help if you are creating multiple GVSIP accounts in FreePBX. You must replace the three items at the top of the file with values you use for oAuth Client ID and Client Secret (you only need one working pair of those, no matter how many accounts you have), and also a one word name for your system (can be anything, when you run it once you'll see how it's used). It then walks you through getting an oAuth Refresh Token (instructions mostly adapted from RonR's previous post), asks for a bit of additional information, and then gives you a suggested configuration. There is no error or sanity checking; "Garbage In - Garbage Out" applies here. This sort of assumes you have created at least one account already and therefore the only configuration information you need is for the new accounts. If you have never created any GVSIP account before, you should probably follow naf's instructions, at least for the [global] context. And also you may need to follow RonR's instructions to get an oAuth Client ID and Client Secret, if you don't already have those. I do things a little differently than others who have posted scripts and I think you will find that if you have several accounts, the way I do things makes it a little bit easier to keep track of your accounts. It works for me, but you are of course free to modify it as you see fit. No error checking, bells, whistles, or frills. Give it a dry run with dummy data to get a sense of what it does. If you're not satisfied, feel free to return it for a full refund. :D One hint to others who write scripts: No, you really don't need any added dialplan in extensions_custom.conf, not to make GVSIP work anyway. If you are using lines of custom dialplan to strip the +1 from the start of the incoming Google Voice number then forget about it and run this script once and it will show you the right way to do that, using the from-pstn-e164-us context in your trunk settings. EDIT: Added reminders to click Submit after creating pages in the FreePBX GUI. Also edited to make it more clear which token you are looking for on the page, since I found out the hard way that if you make a mistake and copy the access token rather than the refresh token, it actually will work for a short time (probably an hour) but then the access token expires and it stops working. You don't want to find out you've used the wrong token after you have done several accounts. Don't ask me how I know that, I don't want to talk about it! :( EDIT 2: Edited to use transport=0.0.0.0-tls rather than transport=transport_tls from naf's original instructions. If this isn't changed, you will get errors when you set tls - 0.0.0.0 - All to YES on FreePBX's Chan PJSIP Settings page (thanks to uid://1917447 for pointing this out to me in the other thread). If you have previously used this script and need to make that change in your existing pjsip_custom_post.conf file, just run sed -i -e 's/transport=transport_tls/transport=0.0.0.0-tls/g' /etc/asterisk/pjsip_custom_post.conf That should change all occurrences in the file. Then remove naf's original [transport_tls] context (all four lines) from your pjsip_custom_post.conf file, and set tls - 0.0.0.0 - All to YES on FreePBX's Chan PJSIP Settings page. #!/bin/bashoAuthClientID="PUT YOUR OAUTH CLIENT ID HERE"oAuthClientSecret="PUT YOUR OAUTH CLIENT SECRET HERE"SystemName="PUT A ONE WORD NAME FOR YOUR SYSTEM HERE (NO SPACES!!!)"echo ""echo ""echo "GVSIP Config Helper"echo ""echo ""echo "Instructions to get Refresh Token:"echo ""echo ""echo "1. Log into the Google Voice account for which you need a token"echo ""echo "2. Go to https://developers.google.com/oauthplayground"echo ""echo "3. Click the gear icon in the top right of the page"echo ""echo "4. Check Use your own oAuth credentials"echo ""echo "5. Enter oAuth Client ID: $oAuthClientID"echo " and oAuth Client secret: $oAuthClientSecret"echo ""echo "6. Click Close"echo ""echo "7. Enter https://www.googleapis.com/auth/googletalk at Input your own scopes"echo ""echo "8. Click Authorize API"echo ""echo "9. Sign into your Google Voice account again if you are prompted to do so"echo ""echo "10. Click Allow"echo ""echo "11. Click Exchange authorization code for tokens"echo ""echo "12. Find the Refresh Token - it is the shorter of the two tokens returned, and appears at a lower position on the page."echo -n " Record the Refresh Token (without the quotation marks) in a safe place and enter it here: "read oAuthRefreshTokenecho ""echo ""echo "Now please enter the following additional information:"echo ""echo -n "Enter the Google Voice account name (the part before @gmail.com): "read AccountNameecho ""echo -n "Enter the 10 digit Google Voice telephone number: "read GVPhoneNumberecho ""echo -n "Enter the account user's name with NO SPACES: "read UserFirstNameecho ""echo -n "Enter the city associated with the Google Voice telephone number, with NO SPACES: "read PrefixCityecho ""echo ""echo "Add the following to the file /etc/asterisk/pjsip_custom_post.conf:"echo ""echo "[gvsip-$AccountName]"echo "type=registration"echo "outbound_auth=gvsip-$AccountName"echo "server_uri=sip:obihai.sip.google.com"echo "outbound_proxy=sip:obihai.telephony.goog:5061\;transport=tls\;lr\;hide"echo "client_uri=sip:$AccountName$GVPhoneNumber@obihai.sip.google.com"echo "retry_interval=60"echo "support_path=yes"echo "support_outbound=yes"echo "line=yes"echo "endpoint=gvsip-$AccountName"echo "contact_additional_params=obn=$SystemName-$UserFirstName-$PrefixCity"echo "transport=0.0.0.0-tls"echo "transport_reuse=no"echo "contact_user=$GVPhoneNumber"echo ""echo "[gvsip-$AccountName]"echo "type=auth"echo "auth_type=oauth"echo "refresh_token=$oAuthRefreshToken"echo "oauth_clientid=$oAuthClientID"echo "oauth_secret=$oAuthClientSecret"echo "username=$AccountName$GVPhoneNumber"echo "realm=obihai.sip.google.com"echo ""echo "[gvsip-$AccountName]"echo "type=aor"echo "contact=sip:obihai.sip.google.com"echo ""echo "[gvsip-$AccountName]"echo "type=endpoint"echo "context=from-pstn-e164-us"echo "disallow=all"echo "allow=ulaw"echo "allow=opus"echo "outbound_auth=gvsip-$AccountName"echo "outbound_proxy=sip:obihai.telephony.goog:5061\;transport=tls\;lr\;hide"echo "aors=gvsip-$AccountName"echo "direct_media=no"echo "ice_support=yes"echo "rtcp_mux=yes"echo "media_use_received_transport=yes"echo "outbound_registration=gvsip-$AccountName"echo ""echo ""echo ""echo "In the FreePBX GUI:"echo ""echo "Add a custom trunk and make the trunk name: GVSIP-$AccountName"echo "Set the Outbound CallerID to: $GVPhoneNumber"echo "In the Dial Number Manipulation Rules tab add the pattern: 1|NXXNXXXXXX and also optionally aaa+NXXNXXXXXX (replace aaa with the assumed area code for 7 digit calls)"echo "In Custom Settings add the Custom Dial String: PJSIP/\$OUTNUM\$@gvsip-$AccountName"echo "Click Submit."echo ""echo "Add an Inbound Route with the Description: Google Voice - $UserFirstName - $PrefixCity"echo "Set the DID Number to: $GVPhoneNumber"echo "Set Destination to the desired extension, ring group, IVR, etc."echo "In the Advanced tab, set Force Answer to YES if you don't want to use Google's Voicemail."echo "In the Other tab, optionally enable a CID Lookup Source, or Enable Superfecta Lookup and select a Superfecta Scheme (probably Default)."echo "Click Submit."echo ""echo "Don't forget to add or modify Outbound Routes to use the GVSIP-$AccountName trunk and click Submit after each."echo ""echo "Click the Apply Config button in FreePBX and wait for the page to reload. If the new account doesn't register within several seconds,"echo "then go to the Asterisk CLI and enter core restart now (this will interrupt any calls in progress) or core restart when convenient"echo "(which will delay the restart until there are no active calls)."echo ""echo ""

Viewing all articles
Browse latest Browse all 6358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>