Aller au contenu principal

oauth

Inscription et autorisation des utilisateurs via OAUTH. Cela renvoie une promesse qui se résout en un objet IAuthEntity.

Description​

La méthode accepte le corps comme paramètre.

.oauth(

, ,

);

Schéma des paramètres​

Schéma

marker(obligatoire): string
L'identifiant textuel du fournisseur d'autorisation
exemple : "email"

body(obligatoire): IOauthData
L'objet contient les informations OAuth pour l'inscription
exemple :

{
"client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
"client_secret": "43434343434",
"code": "4/0AVMBsJgwewewewewewei4D7T6E_fbswxnL3g",
"grant_type": "authorization_code",
"redirect_uri": "http://localhost:3000"
}

body.client_id(obligatoire): string
L'ID client pour l'application OAuth.
exemple : "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com"

body.client_secret(obligatoire): string
Le secret client pour l'application OAuth.
exemple : "43434343434"

body.code(obligatoire): string
Le code d'autorisation reçu du fournisseur OAuth.
exemple : "4/0AVMBsJgwewewewewewei4D7T6E_fbswxnL3g"

body.grant_type(obligatoire): string
Le type de subvention pour la demande OAuth.
exemple : "authorization_code"

body.redirect_uri(obligatoire): string
L'URI de redirection pour l'application OAuth.
exemple : "http://localhost:3000"

langCode: string
Code de langue. Par défaut : "en_US"
exemple : "en_US"

Exemples​

Exemple minimal​


const body = {
"client_id": "34346983-luuct343473qdkqidjopdfp3eb3k4thp.apps.googleusercontent.com",
"client_secret": "43434343434",
"code": "4/0AVMBsJgwewewewewewei4D7T6E_fbswxnL3g",
"grant_type": "authorization_code",
"redirect_uri": "http://localhost:3000"
}

const response = await AuthProvider.oauth('email', body)


Essayez-le en direct​

Exécutez cette méthode de manière interactive dans le bac à sable JS SDK — connectez votre URL de projet et votre jeton d'application lors de votre première visite, puis ouvrez :

  • OAuth — inscrivez et authentifiez un utilisateur via un fournisseur OAuth.