What you’ll learn:
- How OAuth works with Metorial
- Creating OAuth sessions
- Waiting for user authorization
- Using OAuth sessions with your AI models
How OAuth Works
The OAuth flow in Metorial follows a simple 4-step process:- Create an OAuth session for each service that needs user authorization
- Send the authorization URL to your user (they approve access in their browser)
- Wait for completion until the user finishes authorizing
- Use the OAuth session ID when creating provider sessions to give your AI access to user-authenticated tools
Creating OAuth Sessions
When you need to access a service that requires user authorization, create an OAuth session. This generates a unique authorization URL that you send to your user.callbackUrl is where the user will be redirected after they complete authorization. You can use this to show a confirmation page or return them to your application.
Waiting for Authorization
After sending the OAuth URL to your user, your application needs to wait until they complete the authorization flow. ThewaitForCompletion method blocks until the user has authorized (or the request times out).