Google oAuth

How get clientID and secret key

Auth by native app

post
https://api.directual.com
/good/v4/auth
Auth with Google oAuth
1
curl -X PUT -H "Content-Type: application/json" \ https://api.directual.com/good/v4/auth \
2
-d '{
3
"appID":"de87a6f7-a1e5-4b31-9d13-37c842b259a",
4
"provider": "google"
5
"code": "37c842b259a...",
6
"clientID": "de87a6f7....",
7
"redirect_uri": "http://mywebsite.app/login"
8
}'
Copied!

Example auth for React js

Install google-login plugin
1
npm install react-google-login --save
Copied!
Insert login button to your LoginPage template, example:
1
import { GoogleLogin } from 'react-google-login';
2
​
3
<GoogleLogin
4
clientId={you_client_id}
5
buttonText="Login"
6
accessType={"offline"}
7
responseType={"code"}
8
onSuccess={(d)=>{
9
let url = `http://api.directual.com/good/api/v4/auth/`
10
let body = { provider: "google", token: d.code, clientID: you_client_id }
11
fetch(url, {
12
method: 'POST',
13
body: JSON.stringify(req.body),
14
headers: {
15
'Content-Type': 'application/json'
16
}
17
}).then(res2=>{
18
res2.json().then(result=>{
19
res.end(JSON.stringify(result))
20
}).catch((data)=>{
21
res.end('error')
22
})
23
24
})
25
}}
26
onFailure={(d)=>{
27
​
28
}}
29
cookiePolicy={'single_host_origin'}
30
/>
Copied!