API Reference Tips and Tricks v3

API Reference Tips and Tricks v3

Manage your Tokens creation with Postman

Use Postman to manage the creation and renewal of your Access Tokens:

  1. Go to Postman, log in and create a new request:
    • In the new Request, click the Authorization tab and in Type, choose Oauth 2.0
    • Record/copy the Callback URL value.
  2. Create a new Application in Bluescape:
    • See the instructions in Application Authorization, Appendix 1
    • In the Oauth redirect ui field, use the Postman Callback URL value from Step 1.
    • Record/copy the Client ID and Client Secret.
  3. Go back to Postman and fill out the Oauth 2.0 Authorization utility.
  4. In Configure New Token use the following values:
  5. Create the Access Token:
    • Scroll to the bottom of the Postman Oauth 2.0 Authorization utility
    • If available (it depends on the version of Postman being used), click the Clear Cookies button.
  6. Click the Get New Access Token button. A new browser window will open. Follow these steps:
    • Authenticate with Bluescape:
      • Use the same member that created the Bluescape Application. If you are already logged into Bluescape, skip this step.
      • Authorize the Token Creation: click Allow. Bluescape will redirect the process to the Callback URL for Postman. The browser will ask for permission to pass the call to Postman. Allow the link to open.
      • A new window will open in Postman, with the brand new Access Token.
      • Click Use Token on the top-right corner.
  7. The new Access Token is ready to be used in Postman. It can also be used in your scripts.
  8. When the Access Token expires, or you want to generate a new one, click the Get New Access Token button and follow the steps outlined above.

GraphQL Introspection: query the schema

One of the most interesting features of GraphQL is introspection. Introspection is the ability to query details about the current API’s schema. You can send queries to every GraphQL API that returns data about a given API’s schema.

See the following example:
query GetSchema{
  __schema {
    types {
      name
      description
    }
  }
}
The Query Answer will be something like this:
{
    "data": {
        "__schema": {
            "types": [
                {
                    "name": "Browser",
                    "description": "web browser"
                },
                {
                    "name": "Element",
                    "description": "Basic workspace building block"
                },
                ...
        }
    }
}
You can also specify a particular type to get its details:
query ElementDetails {
  __type(name:"Element") {
    name
    fields {
      name
      description
      type {
        name
      }
    }
  }
}
And the answer is this, with the details of the specified type:
{
    "data": {
        "__type": {
            "name": "Element",
            "fields": [
                {
                    "name": "id",
                    "description": "Workspace-unique element id",
                    "type": {
                        "name": null
                    }
                },
                {
                    "name": "zIndex",
                    "description": "Stack order, an element with a higher stack order is in front of a lower stack order",
                    "type": {
                        "name": null
                    }
                },
                ...
            ]
        }
    }
}

Where to Next?

Not what you were looking for? Reply below or Search the community and discover more Bluescape.