Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Authentication issue: The provided credentials are invalid or the user does not exist #437

Open
lacklock opened this issue Mar 17, 2020 · 5 comments

Comments

@lacklock
Copy link

lacklock commented Mar 17, 2020

Goals

using correct ACCESS_TOKEN.TOKEN to query data

Expected Results

Success

Actual Results

Access token request

POST /auth HTTP/1.1
Content-Type: application/json; charset=utf-8
Cookie: INGRESSCOOKIE=a286c04f69f21a6977d4c309021183b3
Host: mobile-log.us1a.cloud.realm.io
Connection: close
User-Agent: Paw/3.1.9 (Macintosh; OS X/10.15.3) GCDHTTPRequest
Content-Length: 765

{"app_id":"io.realm.Auth","provider":"realm","data":RefreshToken ,"path":"/default"}

image

Schema request

https://mobile-log.us1a.cloud.realm.io/graphql/schema/default

GET /graphql/schema/default HTTP/1.1
Authorization:  Token
Cookie: INGRESSCOOKIE=a286c04f69f21a6977d4c309021183b3
Host: mobile-log.us1a.cloud.realm.io
Connection: close
User-Agent: Paw/3.1.9 (Macintosh; OS X/10.15.3) GCDHTTPRequest

Response

HTTP/1.1 401 Unauthorized
Date: Tue, 17 Mar 2020 09:08:57 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 250
Connection: close
Access-Control-Allow-Origin: *
ETag: W/"fa-epKhMUPW/YtdPagazS+IuqIjNmc"
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization

{"type":"https://docs.realm.io/server/troubleshoot/errors#invalid-credentials",
"title":"The provided credentials are invalid or the user does not exist.",
"status":401,"
detail":"The access token doesn't grant access to the requested path.","code":611}

Steps to Reproduce

I want to using graphQL execute query. I have a admin account user. I want to query from the default realm, path is /default .

Post body is:
{
"app_id":"",
"provider":"realm",
"data":"REFRESH_TOKEN.TOKEN",
"path":"/default"
}

But when using the response token put in the Authorization header send request, it will response 401:

{"type":"https://docs.realm.io/server/troubleshoot/errors#invalid-credentials","title":"The provided credentials are invalid or the user does not exist.","status":401,"detail":"The access token doesn't grant access to the requested path.","code":611}

@nirinchev
Copy link
Member

Please post all requests you're making as well as the responses you're getting (feel free to obscure the credentials).

@nirinchev
Copy link
Member

You're sending the request to the wrong endpoint. The route after /graphql is interpreted as the Realm path, so you're trying to query a Realm called /schema/default with a token that grants you access to /default. If you're trying to get the schema of your Realm, the correct way to do it is via the regular GraphQL query API. You can issue a GraphQL request like:

query {
  __schema {
    types {
      name
      fields {
        name
      }
    }
  }
}

That still needs to be sent to /graphql/default like all other queries/mutations affecting that Realm.

@lacklock
Copy link
Author

image

Using query schema on other realm instance is working. But query on /default realm is always reponse 503.

"{\"type\":\"https://docs.realm.io/server/troubleshoot/errors#service-unavailable\",
\"title\":\"The requested service is temporarily unavailable.\",
\"status\":503,\"code\":802}"

@lacklock
Copy link
Author

Why doc says schema endpoint path is /graphql/schema/:path , I thought it means post to endpoint could get schema.
image

@nirinchev
Copy link
Member

The docs seem to be outdated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants