The user selects the Facebook Identity Provider
After you complete Set up your Okta org for a social IdP use case, the Sign in with Facebook link appears automatically on the widget. You don't need to make any code changes to make the link appear.
When the user clicks this link, they’re sent to the Facebook sign-in page.
The user signs in to Facebook
The user enters their email and password, and clicks Log In. The Facebook platform hosts this page. Use the user information from the test user you configured in Set up your Okta org for a social IdP use case. You don't need to make any code changes in your app for this step.
Redirect the request to the Okta org
After the user signs in to Facebook, Facebook routes them to the Valid OAuth Redirect URIs and Site URL values you configured in Create a Facebook app in Facebook. The value has the following format: https://{Okta org domain}/oauth2/v1/authorize/callback
, for example, https://dev-12345678.okta.com/oauth2/v1/authorize/callback
.
Redirect the request to the client
Facebook sends the success sign-in request to your Okta org. The org then redirects the request to your app through the app's Sign-in redirect URIs field.
This step handles the callback from the widget that returns an interaction_code
. This code is redeemed in the next step for tokens. The callback URL must be identical and is defined in these two locations:
For the sample application, the RedirectURI should be set to https://localhost:44314/interactioncode/callback
.
The sample application uses the MVC architecture and defines the following Callback
function in the InteractionCodeController
controller to handle the callback.
Get the tokens
The next step is to call RedeemInteractionCodeAsync
inside the callback function for the IdxClient
. The Interaction Code is used to get the ID and access tokens that you can then use to pull user information.
Persist the tokens in a session
Persist the tokens in session for future use. The following code from the sample application uses IAuthenticationManager
from Microsoft.Owin.Security
to persist these tokens in session.
Depending on your implementation, you can choose to pull user information. When you use the tokens that are provided by the RedeemInteractionCodeAsync
method, you can request the user profile information from the v1/userinfo
endpoint.
The following code from the sample app provides details on this call.