Buckets:
| import { createOAuth2Request, sendTokenRequest } from "../request.js"; | |
| const authorizationEndpoint = "https://api.intra.42.fr/oauth/authorize"; | |
| const tokenEndpoint = "https://api.intra.42.fr/oauth/token"; | |
| export class FortyTwo { | |
| clientId; | |
| clientSecret; | |
| redirectURI; | |
| constructor(clientId, clientSecret, redirectURI) { | |
| this.clientId = clientId; | |
| this.clientSecret = clientSecret; | |
| this.redirectURI = redirectURI; | |
| } | |
| createAuthorizationURL(state, scopes) { | |
| const url = new URL(authorizationEndpoint); | |
| url.searchParams.set("response_type", "code"); | |
| url.searchParams.set("client_id", this.clientId); | |
| url.searchParams.set("state", state); | |
| url.searchParams.set("scope", scopes.join(" ")); | |
| url.searchParams.set("redirect_uri", this.redirectURI); | |
| return url; | |
| } | |
| async validateAuthorizationCode(code) { | |
| const body = new URLSearchParams(); | |
| body.set("grant_type", "authorization_code"); | |
| body.set("code", code); | |
| body.set("redirect_uri", this.redirectURI); | |
| body.set("client_id", this.clientId); | |
| body.set("client_secret", this.clientSecret); | |
| const request = createOAuth2Request(tokenEndpoint, body); | |
| const tokens = await sendTokenRequest(request); | |
| return tokens; | |
| } | |
| } | |
Xet Storage Details
- Size:
- 1.34 kB
- Xet hash:
- 8976e824897f37aa1a66429923dc9d0797491f8b911fda3beb62f6cffc3a7682
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.