During ouath2 authorization with onadata, superset makes a GET request to fetch the user profile details on this endpoint api/v1/user.json. This is a problem because at the point of authorization, authentication credentials are usually stored in the master db before being synced to the read replica db, hence making a GET request will always go to the read replica db which at that point in time might not have the user's details. This results to a 401 error. The best way to handle this, is to make a POST request with no payload to the same endpoint, which will always go to the master db that will always have the user's credentials.
Proposed Implementation
Have superset make a POST request to the api/v1/user.json endpoint.
Remove the subsequent request to the api/v1/profiles/<username>.json endpoint since the api/v1/user.json endpoint has all the user's details required.
Current requirement functionality
This functionality partially exists currently.
User Story
During ouath2 authorization with onadata, superset makes a
GET
request to fetch the user profile details on this endpointapi/v1/user.json
. This is a problem because at the point of authorization, authentication credentials are usually stored in themaster db
before being synced to theread replica db
, hence making aGET
request will always go to theread replica db
which at that point in time might not have the user's details. This results to a401 error
. The best way to handle this, is to make aPOST
request with no payload to the same endpoint, which will always go to themaster db
that will always have the user's credentials.Proposed Implementation
POST
request to theapi/v1/user.json
endpoint.api/v1/profiles/<username>.json
endpoint since theapi/v1/user.json
endpoint has all the user's details required.Required Changes