• Resolved obiwein

    (@obiwein)


    When attempting to register a new token currently getting the error:
    {“error”:”401″,”reason”:”Unauthorized”,”detail”:”Invalid HTTP method”}

    This is when going to the page http://mysitename.com/pnfw/register

    There does not seem to be a suitable answer in the FAQ and documentation sections.
    What should I check?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Delite Studio

    (@delitestudio)

    Hello,

    if you look through the FAQs you’ll find:

    When I call an API the server returns 401 Invalid HTTP method. What should I do?

    As outlined in the documentation some APIs must be called using the POST HTTP method (e.g. the Register API) and other using the GET HTTP method (e.g. the Posts API list). More info here.
    If you are sure you have used the correct HTTP method be sure to check the settings of your web server. In particular, some users have reported that nginx has different URL mapping rules than Apache (see above).

    Thread Starter obiwein

    (@obiwein)

    Yes, I saw that in the FAQ.

    However, is there an example of the correct html page code to actually do the POST command specifically for this API to pull the device ID, etc.?

    Plugin Author Delite Studio

    (@delitestudio)

    Everything you’ll need is in the documentation page, with detailed format for every API.

    Take a look at Chapter 4.1 Register API, you’ll find URL structure, parameters, sample HTTP requests and responses.

    Thread Starter obiwein

    (@obiwein)

    Just tried doing this:
    http://mysite.com/pnfw/register?prevToken=old_device_id&token=new_device_id&os=iOS

    However still results in the same error.
    {“error”:”401″,”reason”:”Unauthorized”,”detail”:”Invalid HTTP method”}

    Plugin Author Delite Studio

    (@delitestudio)

    Please read carefully the documentation.

    You MUST use a POST request, not a GET request.

    Thread Starter obiwein

    (@obiwein)

    Yes I know, but do not understand how to create a form that specifically grabs the correct information and submits it.

    Is there an actual example of the html (and additional script or whatever) to actually capture the email, name, and then hidden fields for device ID and OS, and then submit that information?

    Plugin Author Delite Studio

    (@delitestudio)

    You can use CURL to send POST commands. As an example:

    $ curl http://mysitename.com/pnfw/register/ --data "os=Android&token=test"

    Hope it helps.

    Thread Starter obiwein

    (@obiwein)

    OK, I got as far as getting a web form to actually register a device into the WordPress database.

    However, the token value just pulls in as “device_id” and not the actual long crazy string needed to push to iOS.

    We’re encountering the same issue — even tried sending the CURL command via SSH, with the correct URL and Oauth token. Here’s what we get back in the Debug tab of PNFW Settings:

    /pnfw/register/ API Error (401) from IP address <#.#.#.#>: Unauthorized, Parameter oauth_consumer_key is missing.

    Can you please reply to my support ticket?

    Plugin Author Delite Studio

    (@delitestudio)

    Hello,

    are you sending the oauth_consumer_key parameter as specified in the RFC 5849? Please note the OAuth parameters must be added as query string parameters and not included in the Authorization header. This is because there is no reliable cross-platform way to get the raw request headers in WordPress.

    Yes we are. We’ve tried with and without quotes.

    Hi,

    I am getting an error {“error”:”401″,”reason”:”Unauthorized”,”detail”:”Invalid HTTP method”} on calling the API to register a new token.

    I am passing the following Firebase instance id (as the value for token) and the os value as Android as specified in the documentation. Please confirm if it’s appropriate or if i have done something wrong.

    Thanks in advance!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘New Token Registration Issue’ is closed to new replies.