---
title: "OAuth 2.0 | Tajo"
description: "OAuth 2.0-godkendelse til sikre integrationer med tredjeparter"
url: https://tajo.io/dk/docs/authentication/oauth/
markdown: https://tajo.io/dk/docs/authentication/oauth.md
lang: da-DK
author: "Set Noa"
author_url: https://tajo.io/dk/set-noa/
robots: noindex
---

Bed om tidlig adgang til Tajo

Indtast dit fornavn og din arbejds-e-mailadresse. Vi sender dig et link til at bekræfte din anmodning om adgang til Tajo.

# OAuth 2.0

[Set Noa](https://tajo.io/dk/set-noa/)

OAuth 2.0 giver sikker, tokenbaseret godkendelse, så tredjepartsapplikationer kan tilgå Brevo på vegne af dine brugere.

## Sådan forløber OAuth-flowet

1. **Anmodning om godkendelse**: Send brugeren videre til Brevo
2. **Brugerens godkendelse**: Brugeren giver tilladelserne
3. **Godkendelseskode**: Brevo sender brugeren tilbage med en kode
4. **Udveksling af access token**: Byt koden til tokens
5. **API-adgang**: Brug dit access token til forespørgsler

## Endpoint til godkendelse

```
https://app.brevo.com/oauth/authorize?
  response_type=code&
  client_id=YOUR_CLIENT_ID&
  redirect_uri=YOUR_REDIRECT_URI&
  scope=email%20contacts&
  state=random_string
```

## Udveksling af token

```bash
curl -X POST "https://api.brevo.com/v3/oauth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code&code=AUTH_CODE&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&redirect_uri=YOUR_REDIRECT_URI"
```

## Sådan bruger du dit access token

```javascript
const response = await fetch('https://api.brevo.com/v3/account', {
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'Accept': 'application/json'
  }
});
```

## Scopes

- `email`: Send transaktionelle e-mails
- `contacts`: Styr kontakter og lister
- `campaigns`: Opret og send kampagner
- `sms`: Send SMS-beskeder
- `webhooks`: Styr dine webhooks

## Fornyelse af token

```javascript
const refreshToken = async () => {
  const response = await fetch('https://api.brevo.com/v3/oauth/token', {
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams({
      grant_type: 'refresh_token',
      refresh_token: 'YOUR_REFRESH_TOKEN',
      client_id: 'YOUR_CLIENT_ID',
      client_secret: 'YOUR_CLIENT_SECRET'
    })
  });
  return response.json();
};
```
