Skip to content

Remove documentation for old Twitter Ally driver #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions content/docs/authentication/social_authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ summary: Implement social authentication in your AdonisJS applications using the
You can implement social authentication in your AdonisJS applications using the `@adonisjs/ally` package.
Ally comes with the following inbuilt drivers, alongside an extensible API to [register custom drivers](#creating-a-custom-social-driver).

- Twitter
- Facebook
- Spotify
- Google
Expand Down Expand Up @@ -63,9 +62,9 @@ defineConfig({
clientSecret: env.get('GITHUB_CLIENT_SECRET')!,
callbackUrl: '',
}),
twitter: services.twitter({
clientId: env.get('TWITTER_CLIENT_ID')!,
clientSecret: env.get('TWITTER_CLIENT_SECRET')!,
google: services.google({
clientId: env.get('GOOGLE_CLIENT_ID')!,
clientSecret: env.get('GOOGLE_CLIENT_SECRET')!,
callbackUrl: '',
}),
})
Expand All @@ -76,7 +75,7 @@ OAuth providers require you to register a callback URL to handle the redirect re

The callback URL must be registered with the OAuth service provider. For example: If you are using GitHub, you must log in to your GitHub account, [create a new app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) and define the callback URL using the GitHub interface.

Also, you must register the same callback URL within the `config/ally.ts` file using the `callbackUrl` property.
Also, you must register the same callback URL within the `config/ally.ts` file using the `callbackUrl` property. In many cases, you will want the callback URL to come from an Enviroment variable, or constructed based on a "public url" for your service.
Comment on lines -79 to +78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst this isn't directly related, having language that says "hey, your Callback URL will be different between different environments" is something we should have.


## Usage
Once the package has been configured, you can interact with Ally APIs using the `ctx.ally` property. You can switch between the configured auth providers using the `ally.use()` method. For example:
Expand All @@ -87,15 +86,15 @@ router.get('/github/redirect', ({ ally }) => {
const gh = ally.use('github')
})

router.get('/twitter/redirect', ({ ally }) => {
// Twitter driver instance
const twitter = ally.use('twitter')
router.get('/google/redirect', ({ ally }) => {
// Google driver instance
const google = ally.use('google')
})

// You could also dynamically retrieve the driver
router.get('/:provider/redirect', ({ ally, params }) => {
const driverInstance = ally.use(params.provider)
}).where('provider', /github|twitter/)
}).where('provider', /github|google/)
```

### Redirecting the user for authentication
Expand Down Expand Up @@ -218,7 +217,7 @@ user.token.expiresIn
| Property | Protocol | Description |
|---------|------------|------------|
| `token` | OAuth2 / OAuth1 | The value of the access token. The value is available for the `OAuth2` and the `OAuth1` protocols. |
| `secret` | OAuth1 | The token secret applicable only for `OAuth1` protocol. Currently, Twitter is the only official driver using OAuth1. |
| `secret` | OAuth1 | The token secret applicable only for `OAuth1` protocol. |
| `type` | OAuth2 | The token type. Usually, it will be a [bearer token](https://oauth.net/2/bearer-tokens/).
| `refreshToken` | OAuth2 | You can use the refresh token to create a new access token. The value will be `undefined` if the OAuth provider does not support refresh tokens |
| `expiresAt` | OAuth2 | An instance of the luxon DateTime class representing the absolute time when the access token will expire. |
Expand Down Expand Up @@ -381,20 +380,6 @@ The following is the complete configuration reference for all the drivers. You c

:::

:::disclosure{title="Twitter config"}

```ts
{
twitter: services.twitter({
clientId: '',
clientSecret: '',
callbackUrl: '',
})
}
```

:::

:::disclosure{title="Discord config"}

```ts
Expand Down