Generate Admin Token


#1

I tried to ask this question on the thread Connect Power BI but kept getting Internal Server Errror.

Our Power BI guy tells me he knows how to put a token in the request header. How do we generate and Admin refresh token to give him if we are using Realm Cloud?


#2

You are using GraphQL, correct?

Here’s details on auth and getting a refresh token: https://github.com/realm/realm-graphql-service#authentication


#3

Keep in mind that if you’re using an admin user, you can use the refresh token directly (so stop the instructions after the first response) - you don’t need to exchange the refresh token for an access token.


#4

Thanks for your help so far @nirinchev and @mgeerling, it’s the “power bi guy” here.

I’ve tried encoding the post request for an access token on the /auth endpoint as described here:

{
  "app_id":"",
  "provider":"password",
  "data":"MY-USERNAME",
  "user_info": {
    "register":false,
    "password":"MY-PASSWORD"
  }
}

Which is the equivalent (I think) of this
https://<MY_Server>.cloud.realm.io/auth/%2F%0A%7B%0A%20%20%22app_id%22%3A%22%22%2C%0A%20%20%22provider%22%3A%22password%22%2C%0A%20%20%22data%22%3A%22<MY-USERNAME>%22%2C%0A%20%20%22user_info%22%3A%20%7B%0A%20%20%20%20%22register%22%3Afalse%2C%0A%20%20%20%20%22password%22%3A%22<MY-PASSWORD>%22%0A%20%20%7D%0A%7D

However this is returning a “Cannot GET” response.

Sorry I’m a total non-dev (hence PBI/other tools for simpletons). What is the URL format to return an access token?

Thanks again for your help!


#5

Hi @nirinchev, using Postman to obtain the access token, but no joy. Where am I going wrong?

I’m sending a POST request to https://<MY_SERVER>.<LOCATION>.cloud.realm.io/graphql/auth with the payload in the body and getting a couple of 401 errors (code 611).

{
  "app_id":"",
  "provider":"password",
  "data":"MY-USERNAME",
  "user_info": {
    "register":false,
    "password":"MY-PASSWORD"
  }
}

When I use basic authorization with username/password it returns

{
    "type": "https://realm.io/docs/object-server/problems/invalid-credentials",
    "title": "The provided credentials are invalid or the user does not exist.",
    "status": 401,
    "detail": "The tokenString parameter does not have 2 parts separated by a colon (':')",
    "code": 611
}

and with bearer token authorization (with MY-USERNAME:MY-PASSWORD in the header)

(AS ABOVE)
“detail”: “The token data could not be verified against its signature”,
“code”: 611

And with no authorization header the result is “missing parameters”.

Thanks for your help!