jaraco / googlevoice

Python Google Voice library based on pygooglevoice
MIT License
111 stars 32 forks source link

Wrapping around the new google voice API? #7

Open tobocop2 opened 5 years ago

tobocop2 commented 5 years ago

@jaraco

So this is not an issue at all, but I've been depending on this module to send and receive messages inside of weechat. However, the old API does not support group messages fully. It can only receive messages and not send. In order to send, one needs to use the new google voice API.

In an absolutely quick and dirty attempt to get group messages working, I "reverse engineered" the "send/receive portions

You can see the implementation as proof of concept here:

Send SMS with new API

Inside of

send_sms, get_sms

The good about moving to the new API

The bad

jaraco commented 5 years ago

I'd be enthusiastically in support of this change. I won't have time to work on it, but I'd gladly accept pull requests and help guide a new release with this functionality.

tobocop2 commented 5 years ago

@jaraco I will start taking a stab at it.

tobocop2 commented 5 years ago

@jaraco

So I managed to figure out how to make the code referenced in my initial post almost dynamic. I managed to figure out how the SAPISID hash was being generated from the client side and I figured out the bare essential headers that were necessary to send over with the request. I updated the link to point to the current implementation.

The only thing that I have not figured out is how to retrieve the API key dynamically. It's very easy to obtain and is part of the query string on every request POST when sending a message. I still need to do some digging to get the key.

If this is possible, I wll then start figuring out how to port over functionality to the new API. At the very least, I will add support for receiving and sending SMS with tne new api as that is likely the most important feature of this module (in my opinion)

jeremysmiley commented 5 years ago

@tobocop2 Would you mind sharing where you found the info an the google voice API? I've been looking but don't see any mention of it anywhere. Thanks!

tobocop2 commented 5 years ago

@jeremysmiley It's not a public API, I just played around with the developer console and figured out how to send and receive SMS with the new API. My issue however is the requirement of a private API key that must be sent with every request in addition to all of the previous headers. I spent a few hours trying to figure out how to dynamically retreive that API key but haven't had much more time to dig into it. My code currently relies on the fact that I copied my API key from one of my outgoing requests that I saw in the developer console.

jeremysmiley commented 5 years ago

Interesting, thanks for the info. I'm looking for a solution for our small biz. We use Google Voice for our business line and it would be awesome if I could setup a zapier automation to send out automated sms messages for follow-ups and reminders for our clients. Right now we use a Twilio number to do this but it would be ideal to use the same number throughout all of our communication.

On 1/19/19, Tobias notifications@github.com wrote:

@jeremysmiley It's not a public API, I just played around with the developer console and figured out how to send and receive SMS with the new API. My issue however is the requirement of a private API key that must be sent with every request in addition to all of the previous headers. I spent a few hours trying to figure out how to dynamically retreive that API key but haven't had much more time to dig into it. My code currently relies on the fact that I copied my API key from one of my outgoing requests that I saw in the developer console.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/jaraco/googlevoice/issues/7#issuecomment-455829405

--


Jeremy Smiley, Realtor London Properties C: 559-790-8760 www.OurFresnoRealtor.com http://www.ourfresnorealtor.com/ www.FreeFresnoValues.com http://www.freefresnovalues.com/

The information provided in this transmission was provided to sender from sources believed to be reliable; however, it has not been verified or confirmed and neither London Properties Ltd. nor its agents make any warranty or representation regarding its accuracy, completeness, or reliability. Recipient should not rely on this information prior to independent verification. This transmission may also contain confidential information that is legally privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the transmitted information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply email or by telephone and permanently delete this transmission. Thank you.

tobocop2 commented 5 years ago

@jeremysmiley

You should have no problems using this python package as is to do what you are trying to do. It works fine for the use case that you just described. I only opted to figure out how the new API works (to a degree) because I couldn't send group messages to friends.

jeremysmiley commented 5 years ago

Nice. Thank you.

jeremysmiley commented 5 years ago

Can you tell me where you found the new API info? I looked in the developers section and there A LOT of APIs I don't anything pertaining to voice.

On Sat, Jan 19, 2019, 6:01 PM Tobias <notifications@github.com wrote:

@jeremysmiley https://github.com/jeremysmiley

You should have no problems using this python package as is to do what you are trying to do. It works fine for the use case that you just described. I only opted to figure out how the new API works (to a degree) because I couldn't send group messages to friends.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jaraco/googlevoice/issues/7#issuecomment-455830984, or mute the thread https://github.com/notifications/unsubscribe-auth/Asrzm8lVLQ3AUO-_Fu8KuOqhXxY0hv8Bks5vE84OgaJpZM4Zg1T9 .

tobocop2 commented 5 years ago

@jeremysmiley

There is no official API. The authors of this python package reverse engineered the now legacy version of google voice.

In order to programmatically use google voice, the simplest solution is to use this wrapper.You will not find API info for google voice. The official google voice API is obfuscated and undocumented externally and the service is not intended to be used like Twilio. However, thanks to this package, one is able to use google voice similarly to the python twilio api wrapper. Just bare in mind, that the legacy version of google voice may one day be taken down (doesn't seem likely though) and this package will no longer be functional whereas the Twilio python sdk will likely work the same and be reliable moving forward.

jeremysmiley commented 5 years ago

Thanks.

On Sat, Jan 19, 2019, 10:20 PM Tobias <notifications@github.com wrote:

@jeremysmiley https://github.com/jeremysmiley

There is no official API. The authors of this python package reverse engineered the now legacy version of google voice.

In order to programmatically use google voice, the simplest solution is to use this wrapper.You will not find API info for google voice. The official google voice API is obfuscated and undocumented externally and the service is not intended to be used like Twilio. However, thanks to this package, one is able to use google voice similarly to the python twilio api wrapper. Just bare in mind, that the legacy version of google voice may one day be taken down (doesn't seem likely though) and this package will no longer be functional whereas the Twilio python sdk will likely work the same and be reliable moving forward.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jaraco/googlevoice/issues/7#issuecomment-455841249, or mute the thread https://github.com/notifications/unsubscribe-auth/Asrzm8LYv-wHKWYrPSxLujVeawi6QeCYks5vFArKgaJpZM4Zg1T9 .

slow-quick commented 5 years ago

@tobocop2 Somehow the googlevoice package no longer works for me. I've checked all my GV settings and couldn't think of any changes. It has a login issue.

I would like to try your "new api" approach but it seems need an "api_key" in addition to my email and password. How do I get that api_key? Thakks!

tobocop2 commented 5 years ago

@slow-quick

I get login issues with the legacy API as well. It could be a bug in the legacy system, but some time needs to be spent reverse engineering the new login API. I haven't gotten around to doing that yet. I'm still using the old legacy API to login and then I'm passing the cookies stored in that session to the new API and that works for now, but at work, I get semi-regular "LoginError" exceptions while at home I do not. It is likely a bug with the legacy login wrapper. I'd like to figure out how the new login system works and to update this package at some point in the near future. Until I figure that out, I wouldn't bother tryign to incorporate my changes into this.

My "new" approach still depends on the login wrapper from this module, so it unfortunately will not solve your problem. I updated the link in the original post so you can see how I got the api key. However, it won't help your login issue.

xloem commented 4 years ago

I might consider recommending to move towards using headless selenium for this so that it is easier for more people to maintain.

jaraco commented 4 years ago

If considering headless selenium, I'd recommend splinter. I used that on another project and found it much easier to use than Selenium. In my experience, the biggest problem with any Selenium-based solution is integration. Last I checked, any headless browser approach requires careful, platform-specific configuration to get working. That was a few years ago. Perhaps it's better now.

cvincent commented 2 years ago

I'd like to take a look into this. Based on speaking with someone else, the new internal API referred to here might be based on protocol buffers? Just to confirm and make sure I'm not repeating work, is that the same thing you saw @tobocop2?

tobocop2 commented 2 years ago

yep it is using protocol buffers, I just was easily able to infer the data using the shape of the payload. bear in mind however that the original post here is almost 3 years old and I think the api has considerably changed since then, I'm just going based on what i saw back then.

It would be awesome to fully wrap the google voice api with push notifications and to create an IRC bridge around google voice with push notifications and all.

GeorgeHahn commented 2 years ago

Note that the API appears to have a JSON option now. It can be selected by switching the alt parameter from protojson to json.