react-42-login
A 42 oauth Sign-in / Log-in Component for React
Install
$ npm install --save react-42-login
Or using yarn
$ yarn add react-42-login
Usage
;;; const log = console; ReactDOM;
Because it's a oauth login we need to send the request from the server to keep the app secret safe.
// server side nodejsapp
If you are not using nodejs you have to setup a route who's going to call the api.
First POST https://api.intra.42.fr/oauth/token With this body
body: grant_type: 'authorization_code' client_id: your_app_id client_secret: your_app_secret code: from_previous_body_code redirect_uri: from_previous_body_redirect_uri
Then GET https://api.intra.42.fr/v2/me With this header
headers: Authorization: "Bearer " + from_previous_call_access_token
Parameters
params | type | required | default |
---|---|---|---|
scope | string | ❌ | public |
className | string | ❌ | |
style | object | ❌ | |
onSuccess | function | ✅ | |
onFailure | function | ✅ | |
clientId | string | ✅ | |
children | node | ✅ | |
route | string | ✅ | |
redirectUri | string | ✅ |
Demo
You can check the demo.
$ git clone https://github.com/MRdotB/react-42-login
$ yarn or npm i
$ yarn start or npm run start
License
MIT © mrdotb