# Socialite Redirect

Socialstream generates the OAuth redirect for a provider using the following logic:

```php
Socialite::driver($provider)->redirect()
```

You may find you want to alter this logic; for example, you may wish to alter the scopes requested from the provider at runtime. To do so, simply update the `generate` method of your applications `app/Actions/Socialstream/GenerateRedirectForProvider.php` action file:

```php
public function generate(string $provider): RedirectResponse
{
    $scopes = ['*'];

    if ($provider = 'github' && config('services.github.manage_repos') {
        $scopes = array_merge($scopes, [
            'repos.manage',
        ]);
    }
    
    return Socialite::driver($provider)
        ->scopes($scopes)
        ->with(['response_type' => 'token'])
        ->redirect();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.socialstream.dev/getting-started/customization/socialite-redirect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
