You can run queries on real Scope data using any HTTP compliant client (HTTP Client) or GraphQL integrated development environment (GraphQL IDE). GraphQL IDEs are typically easier to work with because they include docs, syntax highlighting, and validation errors.
...
Code Block |
---|
https://cms.scopear.com/api/v3/graphql |
The endpoint remains If you are not a super admin, the endpoint can remain constant no matter what operation you perform. If you are a super admin, you must include the company permalink name in the URL. In this example, the company permalink name is scope
Code Block |
---|
https://cms.scopear.com/api/v3/graphql/?permalink=scope |
Note that users other than super/company admins can now use GraphQL to run queries.
About the Scope GraphQL Explorer
Scope GraphQL Explorer is an instance of GraphiQL (a GraphQL IDE) that is available in-browser at https://cms.scopear.com/api/v3/graphql/explorer.
Note |
---|
Note: The Scope GraphQL Explorer has been temporarily disabled, but you can still explore the graph using a local GraphiQL client, or any other similar client (see below). |
Using GraphiQL
To use the GraphiQL app, download and install it from https://www.electronjs.org/apps/graphiql.
Configuring GraphiQL
Get an OAuth token.Getting an OAuth token can be done thru CMS
Log in to CMS as your authorized user and open the Developers Console (F12 usually does this)
Open the Application tab and copy the Auth token from Cookies
Ensure the authenticated user has the Access Control Rights required by the query to be executed (See Authorization Errors & Reporting Admins).
Launch GraphiQL.
In the upper-right corner of GraphiQL, click Edit HTTP Headers.
If you don’t already have GraphiQL setup with Headers, do the following;
In the upper-right corner of the modal dialog, click + Add Header.
In the Key field, enter
Authorization
. In the Value field, enterToken token=<token>
, where<token>
is your generated OAuth token.Click
Save to save the
token
.
In the upper-right corner of the modal dialog, click + Add Header.
In the Key field, enter
PrivateAccessCode
. In the Value field, enterToken token=YWRtaW4xMjU6c2VjcmV0MTI1
, whereYWRtaW4xMjU6c2VjcmV0MTI1
is a literal value (used to enable early access to the Scope GraphQL API).Click
Save to save the
token
.
To return to the editor, click outside of the Edit HTTP Headers modal.
In the GraphQL Endpoint field, enter
https://cms.scopear.com/api/v3/graphql
. enter the following (include company permalink if necessary)In the Method dropdown menu, select POST.
...
You must obtain a valid OAuth token before attempting to execute queries against, or explore the schema of, the Scope API.
Obtaining an OAuth token
Use your favorite HTTP client to sign in:
Code Block |
---|
curl --request POST \
--url https://cms.scopear.com/api/v2/users/sign_in.json \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'user[username]=YOUR_URL_ENCODED_EMAIL' \
--data 'user[password]=YOUR_URL_ENCODED_PASSWORD' |
...
Parse the response as JSON and extract the value for the auth_token
key (e.g. the following response should yield the following token):
Code Block |
---|
{
"id": 1,
"email": "support@scopear.com",
"name": "Support Account",
"permalink": "supportscopearcom",
"username": "support@scopear.com",
"guest": false,
"auth_token": "eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InVzZXJfaWQiOjEsImRldmljZV9pZCI6MX0sImV4cCI6MTYwODI0NDA3MSwianRpIjoiOGY3ODg1NTg2Y2Y4YTdiNjQ1MWIwZTcxMzFhODY1MDE2MmQwZWZhZjc3MTgwYTNhZmU5OTk2N2Y4OTZhNzlhOCIsImlhdCI6MTYwNTY1MjA3MX0.Z4hFOmLlUPolvW3u-2Ssn7LWX_c2y95a1fhID3QJuCg",
... |
=> eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InVzZXJfaWQiOjEsImRldmljZV9pZCI6MX0sImV4cCI6MTYwODI0NDA3MSwianRpIjoiOGY3ODg1NTg2Y2Y4YTdiNjQ1MWIwZTcxMzFhODY1MDE2MmQwZWZhZjc3MTgwYTNhZmU5OTk2N2Y4OTZhNzlhOCIsImlhdCI6MTYwNTY1MjA3MX0.Z4hFOmLlUPolvW3u-2Ssn7LWX_c2y95a1fhID3QJuCg
You may now use this token wherever an OAuth token is required (until it expires).
Refreshing an OAuth token
Scope OAuth tokens currently expire after 30 days (or “sign-out”, whichever is earlier).
...
Repeat steps 1-5 to obtain a fresh token thru the developers console.