And the only thing that is left is basically to use this middle row.
Okay. I'm going to start the application again and let's see what happens.
Okay. So we can see that all our requests returning 401.
Okay. So what we need to do is to send the session token in every request.
So we are going to basically go to the dashboard page. This is the place that fires the request to get the information and we are going to add a headers and in the headers, we are going to add the authorization header.
We are going to do something like Bearer and here we are going to want to pass the session token.
So the Dhiscope SDK has a functionality for it, get session token and we can use it.
Let's start.
Okay, so let's see the application right now.
And you can see that now the application returns the information.
We can see that the request, if we go to the request headers, we can see that on the authorization header, the session tokens, which is the alphanumeric long string here, are presented.
And this was the overall end-to-end authorization process.
So we added in the login, we added the two-step login process, which is sending the email and verifying the code.
And then we use this session, we send it to the server and we added the middleware in the server.
In the last few minutes that we have, I want to also implement the social login part.
And the social login is probably very similar to the OTP in terms of implementation.
Let me just copy-paste the implementation from a branch that I have on the site.
So we won't spend too much time on it.
And we're going to go to the login and here in the button of the social login with Google, basically we are going to replace this implementation like basically we're going to go to the SDK that we imported from the use this scope and we're going to call the Google part.
This will handle, this will start the OAuth process and we're going to take the response URL and redirect the user to that response.
And the other part that is missing here is that we are going to basically add a use effect and the user effect here will going to handle what happens when the user is returned from a Google.
So we are basically going to get the code from let me just import before and we're going to use the user search param from react router dom.
And here we are going to get the code from the search param and we're going to do the exchange part.
So OAuth is basically compound with two process.
You start the process when the user clicks the button, this will redirect the user to Google.
And when the user is backed to the page, we are going to redirect them here.
Comments