Giter Club home page Giter Club logo

Comments (9)

alibitek avatar alibitek commented on May 31, 2024

@bauerj I pressume you are using the pypi version, which is a bit old and will hopefully be updated soon. That version of python-gcm doesn't handle MissingRegistration error received from the GCM server in the raise_error. This problem has been fixed in master branch.
Also in that version there is also a validation made inside the plaintext_request method right at the beginning for the registration_id to be not None, but if your stack trace goes to raise_error it means that the error is coming from the GCM server.

For debugging purposes you can either use a debugger or manually alter the gcm.py file that you have installed on your machine and inside the make_request method add two log statements for the following two things and tell use the output:

  1. Print the request data, add a log statement for the data parameter right before the requests.post call is made to see exactly what the HTTP request data looks like
  2. Print the response data, add a log statement for the response.content right after the requests.post call is made to see exactly what GCM server sends back.

from python-gcm.

bauerj avatar bauerj commented on May 31, 2024

Hi,

I already did that: The data variable contains what I posted above and the response only contains Error=MissingRegistration.

And yes, I'm using the latest version from pypi.

from python-gcm.

alibitek avatar alibitek commented on May 31, 2024

OK. So the above data is what you have right before making the HTTP request.
I'm interested in the exact response from the requests library not what you get back from python-gcm after processing the response, the response content should have more information.

from python-gcm.

alibitek avatar alibitek commented on May 31, 2024

@bauerj I think one more thing is happening. Double URL encoding.
Even though I'm not authorized to send the request I've tried to debug the HTTP request using Wireshark and I see this when using as id fUxwjeZSVR0%3AAPA91bFfRy0DcYw_gxsMd86FEUdwhR6SrvAV46AHhSeWydnYtLMCvza055jXW-e-j-ETDGGCbVaMBN7TdKR8VvdkqLr_pofWkQcsb1o9FE7kqciPvXxYrxYvp98jZttDZSxe3f8dvuM7

POST /gcm/send HTTP/1.1
Host: gcm-http.googleapis.com
Accept: */*
Authorization: key=123api
Content-Length: 244
User-Agent: python-requests/2.8.0
Accept-Encoding: gzip, deflate
Connection: keep-alive

registration_id=fUxwjeZSVR0%253AAPA91bFfRy0DcYw_gxsMd86FEUdwhR6SrvAV46AHhSeWydnYtLMCvza055jXW-e-j-ETDGGCbVaMBN7TdKR8VvdkqLr_pofWkQcsb1o9FE7kqciPvXxYrxYvp98jZttDZSxe3f8dvuM7&data.address=9GWXR4aD6JSb6DMPxAKH9GeGrBDjhRyxuf&data.amount=36.11628274

%3 = :
%3 = %253
=> Double URL/percent encoding is happening

Can you please manually edit the gcm.py file of your installation and delete the following two lines in the make_request method and retry the request:

 if not is_json:
            data = urlencode_utf8(data)

The requests HTTP client library already does URL encoding so I think this might be the problem, let me know.

from python-gcm.

alibitek avatar alibitek commented on May 31, 2024

@bauerj Any news?

from python-gcm.

bauerj avatar bauerj commented on May 31, 2024

Sorry, I was busy earlier today.

Yes, this seems to solve the issue for me.

from python-gcm.

alibitek avatar alibitek commented on May 31, 2024

In that case it seems like the plaintext_request was not tested enough before changing to requests library.
This problem is fixed in the master branch.

from python-gcm.

bauerj avatar bauerj commented on May 31, 2024

Okay, when will it be fixed on Pypi?

from python-gcm.

alibitek avatar alibitek commented on May 31, 2024

@bauerj I will discuss with @geeknam about the next release, we will do it soon.

from python-gcm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.