Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping around the new google voice API? #7

Open
tobocop2 opened this issue Dec 25, 2018 · 18 comments
Open

Wrapping around the new google voice API? #7

tobocop2 opened this issue Dec 25, 2018 · 18 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@tobocop2
Copy link

tobocop2 commented Dec 25, 2018

@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 new google voice API seems nice and modern and returns json payloads
  • No longer a need to parse html and can remove beautiful soup dependency
  • Potentially faster response times
  • An API key can now be passed around instead of logging in with plain text auth (I think...that is how I am doing it now)

The bad

  • This package would basically need to be re-written to wrap around the new API
  • Authentication might be more complicated (I haven't dug into the source here much so it might be of similar complexity)
  • The request post body is strangely formatted.
@tobocop2 tobocop2 changed the title Would you have interest in wrapping around the new google voice API? Wrapping around the new google voice API? Dec 25, 2018
@jaraco
Copy link
Owner

jaraco commented Dec 26, 2018

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.

@jaraco jaraco added enhancement New feature or request help wanted Extra attention is needed labels Dec 26, 2018
@tobocop2
Copy link
Author

@jaraco
I will start taking a stab at it.

@tobocop2
Copy link
Author

tobocop2 commented Dec 30, 2018

@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
Copy link

@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
Copy link
Author

@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
Copy link

jeremysmiley commented Jan 20, 2019 via email

@tobocop2
Copy link
Author

@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
Copy link

Nice. Thank you.

@jeremysmiley
Copy link

jeremysmiley commented Jan 20, 2019 via email

@tobocop2
Copy link
Author

@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
Copy link

jeremysmiley commented Jan 20, 2019 via email

@slow-quick
Copy link

@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
Copy link
Author

@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
Copy link

xloem commented Jun 28, 2020

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

@jaraco
Copy link
Owner

jaraco commented Jun 28, 2020

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.

jaraco added a commit that referenced this issue Nov 17, 2020
@cvincent
Copy link

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
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants