Getting error 502 when using REST API to retrieves

2019-09-15 11:28发布

GET /imfpush/v1/apps HTTP/1.1
Host: mobilefoundation-3b-mf-server.mybluemix.net
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImp....
Content-Type: application/json

another type of invocation

curl -X GET -H "Authorization: Bearer eyJhbGciOiJSUzI1N...." "https://mobilefoundation-3b-mf-server.mybluemix.net/imfpush/v1/apps"

Error 502: Failed to make token request, reason: Unsuccessful request to Authorization Server, server responded with status code: 400 and body : {"errorCode":"invalid_client"}, check the Authorization URL: http://localhost:8080/mfp/api/az/v1/token

1条回答
地球回转人心会变
2楼-- · 2019-09-15 11:49

TL;DR: right now looks like there is a bug in the /imfpush/v1/apps endpoint where it does not filter the applications by the vendor (APNS, GCM, WNS), so you can only get a list of all applications instead...


Note however that it all depends on your end goal. You can accomplish this by code or by using tools such as curl or Postman, Swagger etc... it all depends on what you want to achieve.

Here are 3 ways:

  1. In the local development server - not available in Mobile Foundation service on Bluemix, you can use this URL to see the REST endpoints exposed in Swagger. You can then view push-enabled applications with this one: http://localhost:9080/doc/?url=/imfpush/v1/swagger.json#!/Applications/getAllApplications

    • First, in MobileFirst Operations Console > Runtime Settings > Confidential clients:
    • Add (just an example, choose your own) a new user client (id: user, secret: user)
    • Add the apps.read and push.application.* scopes

    Be sure to click on the knob and add the apps.read and push.applications.* scopes.

    You will also be asked to authorize. Use the username and password for the user confidential client that you previously created.

enter image description here

  1. Using the /imfpush service, as described below.
  2. Using the mfpadmin service, as described below.

In my examples I will use Postman.


  1. In MobileFirst Operations Console > Runtime Settings > Confidential clients:

    • Added (just an example, choose your own) a new user client (id: user, secret: user)
    • Added the apps.read and push.application.* scopes
  2. Obtained an access token by making a POST request to http://localhost:9080/mfp/api/az/v1/token with:

    Authorization tab:

    • Type: Basic Auth
    • user: user
    • password: user

    Body tab:

    • x-www—form-urlencoded
    • grant_code: client_credentials
    • scope: apps.read push.application.*
  3. Obtained the list of applications by making a GET request to http://localhost:9080/imfpush/v1/apps with:

    Headers tab:

    • Authorization: Bearer the-access-token-from-step-2
  4. To filter the list by platform, the URL should change to the following, like the example in the API documentation: http://localhost:9080/imfpush/v1/apps/?expand=true&filter=platform==A&offset=0&size=10 But since this does not work right now... use: http://localhost:9080/imfpush/v1/apps/

Of course, you need to change localhost to your server's host.

enter image description here


To only obtain a list of all applications, it'd be faster to use the mfpadmin service applications endpoint. Using Postman:

  1. Created a new GET request to http://localhost:9080/mfpadmin/management-apis/2.0/runtimes/mfp/applications

    You can change the domain to yours.

  2. In the Authorization tab, I have set the following:

    • Type: Basic Auth
    • Username and Password: your username and password (to the console)

In return I have received a list of registered applications.

enter image description here

查看更多
登录 后发表回答