Files
supabase/apps/reference/_supabase_js/generated/auth-admin-generatelink.mdx
2022-08-18 15:54:30 +08:00

241 lines
4.9 KiB
Plaintext

---
id: auth-admin-generatelink
title: 'generateLink()'
slug: /auth-admin-generatelink
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Generates links to be sent via email or other.
```js
const { data, error } = await supabase.auth.admin.generateLink(
'email@example.com'
'signup',
{
'password': 'secret'
}
)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
GenerateLinkType
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>signup</code> | <code>invite</code> | <code>magiclink</code> | <code>recovery</code> | <code>email_change_current</code> | <code>email_change_new</code>
</span>
</h4>
<div class="method-list-item-description">
The link type
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email_change_new
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
literal
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email_change_current
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
literal
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
recovery
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
literal
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
magiclink
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
literal
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
invite
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
literal
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
signup
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
literal
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's email.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should only be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Generate a signup link.
```js
const { data, error } = await supabase.auth.admin.generateLink(
'email@example.com'
'signup',
{
'password': 'secret'
}
)
```
### Generate an invite link.
```js
const { data, error } = await supabase.auth.admin.generateLink(
'email@example.com'
'invite',
)
```