I'm getting unauthorized (401) error while GET req...
# support-questions-legacy
a
I'm getting unauthorized (401) error while GET request from the backend (Django). Both frontend and backend has the same cookies. Earlier I used to get access token in the local storage but now there's no access token.
r
Hey. Can you enable backend debug logs and show me the output?
a
Copy code
"OPTIONS /auth/authorisationurl?thirdPartyId=MS HTTP/1.1" 200 0
"GET /auth/authorisationurl?thirdPartyId=MS HTTP/1.1" 200 211
"OPTIONS /auth/signinup HTTP/1.1" 200 0
"POST /auth/signinup HTTP/1.1" 200 263
"OPTIONS /viewer/ HTTP/1.1" 200 0
Unauthorized: /viewer/
"GET /viewer/ HTTP/1.1" 401 26
"OPTIONS /viewer/ HTTP/1.1" 200 0
Unauthorized: /viewer/
"GET /viewer/ HTTP/1.1" 401 26
"OPTIONS /viewer/ HTTP/1.1" 200 0
Unauthorized: /viewer/
"GET /viewer/ HTTP/1.1" 401 26
"OPTIONS /viewer/ HTTP/1.1" 200 0
Unauthorized: /viewer/
"GET /viewer/ HTTP/1.1" 401 26
"OPTIONS /viewer/ HTTP/1.1" 200 0
Unauthorized: /viewer/
"GET /viewer/ HTTP/1.1" 401 26
"OPTIONS /viewer/ HTTP/1.1" 200 0
Unauthorized: /viewer/
"GET /viewer/ HTTP/1.1" 401 26
r
Ahh no. These aren’t the debug logs generated by supertokens
See the troubleshooting section in the docs
a
Ok
In the docs it says run python app.py which py file should I mention
r
the one that you use to start your backend server
a
I tried with manage.py runserver but didn't get the output.
r
Are you calling supertokens.init in your code?
On the backend
a
Copy code
init(
    app_info=InputAppInfo(
        app_name="Sup",
        api_domain="http://localhost:8000",
        website_domain="http://localhost:3000",
        api_base_path="/auth",
        website_base_path="/auth"
    ),
    supertokens_config=SupertokensConfig(
        connection_uri='.....
',
        api_key='....'
    ),
    framework='django',
you mean this?
r
Yes
Also, you should probably change ur api key now. Since you made it public here
If no logs r being printed, it means you haven’t set the env var correctly
a
Okay I'll look into it
I'm getting this now
Copy code
Session does not exist. Are you sending the session tokens in the request as cookies?
r
Can you show me the request headers for the API call being made from the browser?
a
r
I see. Are you using axios on the frontend?
when u make the APi call
a
yes
r
which version of the frontend SDK are you using?
and which frontend SDK?
a
r
can you update to 0.27.0 for supertokens-auth-react and try again?
a
Ok
now i'm unable to login
it's going for refresh call
r
can you elaborate?
and can i see all the cookies that are being sent?
a
while login the refresh call is unauthorized
r
what are the cookies that are sent to it?
and also, what are the response headers from the login API?
can you also enable frontend debug logs and show me the output
a
Oh my bad
I referred a similar thread and you said set the same_cookie param to "none"
I removed this param
now it's working
r
ok nice!
a
thanks a lot
5 Views