How do you connect to the GraphQL explorer on Realm Cloud?

cloud

#1

I am trying to connect to the GraphQL explorer on my Realm Cloud instance. How do I do this? The documentation says “If you’re using Chrome, you can use an extension, such as ModHeader to inject the header into your requests”. What header fields are needed? I have tried a bunch of different variants but all fail with the message “The token data could not be verified against its signature”


#2

The header you need is Authorization. The URL will be something like https://YOUR_INSTANCE_NAME.us1a.cloud.realm.io/graphql/explore/%2FYOU_REALM_NAME


#3

Yes, you need to set the authorization header and pass in an access token obtained by authenticating against ROS. You can read more about it in the Authentication section of the GraphQL service docs.


#4

Thanks! I will try that. I did look thorugh the documentation at https://docs.realm.io/platform/graphql-web-access/graphiql-explorer, but it doesn’t seem complete.


#5

Hi @nirinchev , I’m posting the username/password in the recommended payload to get a refresh token to https://MY_REALM_NAME.us1a.cloud.realm.io/graphql/auth but am receiving “The authorization header is missing”

What do I need to pass in the authorisation header in order to get an access or refresh token?


#6

You should be posting it to instance-url/auth not instance-url/graphql/auth.


#7

Thanks @nirinchev, I just tried that URL with the recommended payload and received:

{
    "type": "https://realm.io/docs/object-server/problems/missing-parameters",
    "title": "Your request did not validate because of missing parameters.",
    "status": 400,
    "code": 602,
    "invalid_params": [
        {
            "name": "provider",
            "reason": "Missing parameter 'provider'!"
        }
    ]
}

The provider is being passed in the body payload as per the instructions, does it need to be sent in another method as well?


#8

You need to end the request body as application/json


#9

@seann I’m terribly sorry, this must have flown under my radar. Did you manage to get it working? As @mbritto said, it could be caused by an incorrect content-type header, but if you share the payload of your request (you can obfuscate passwords/usernames), it’d be easier to spot what’s wrong with it.


#10

The documentation says we should set Authorization header like this :

Authorization: ACCESS_TOKEN.TOKEN

But when we do (and replace ACCESS_TOKEN.TOKEN with our long token), we get this error from the server : “The tokenString parameter does not have 2 parts separated by a colon (’:’)

Has something changed on the expected format for the header ?


#11

Not really - this code path hasn’t changed in a very long time. Are you sure you’re copying the entire access token and not just half of it? E.g. this is how an access token for one of my instances looks like:

eyJhcHBfaWQiOiJpby5yZWFsbS5BdXRoIiwiaWRlbnRpdHkiOiJyZWFsbS1hZG1pbiIsImFjY2VzcyI6WyJkb3dubG9hZCIsInVwbG9hZCIsIm1hbmFnZSJdLCJzYWx0IjoiMjVhYzM4OTkiLCJleHBpcmVzIjoxNTM4NTE5NjI5LCJwYXRoIjoiL19fYWRtaW4iLCJzeW5jX2xhYmVsIjoiZGVmYXVsdCJ9:ZF4bj0Ez5Qga3ur5JKRJVRrLrpaDq2DMqJ9mimqTd9qKMArpULzJb0MdLxFVzyY6kotHJBtFPvXBVrt24ZclOsDwB7AvhqD4LYFKW0Dc1ZTbBEx36FJuP5sR50bB9bbsjUjqUxU55bwbSaDCnl/AU3ivM7IR4081VBfRGb4jb5rODyaB6F9bqhTov5Oo2iAM0+JfBoxXHBjeEPb8RkXT5PU9RAbcxvBEuDyugmrnz2kuwz/AwzWCJjRsTKaBfuTj1P7/vxFe6NXHtRFgv5p1DCLnozDCHwvjoRXH5VjP7UiMTWtZ3lqneHay5yhfvRISbjBd701Z7CyUfqjKewoezg==

Notice how it’s composed of two segments with a colon between them. Does your token have a similar format?


#12

:scream: Paw was truncating it in JSON mode, after choosing raw response mode I could see the whole token, with the colon.
Thanks you saved me :slight_smile: