Skip to content

Commit 13dc673

Browse files
authored
Merge pull request #2 from IOsonoTAN/master
Add how to use it into README.md
2 parents 071ee50 + 0318cff commit 13dc673

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
1-
# parse-server-firebase-auth-adapter
1+
# Parse-server-firebase-auth-adapter
22
Authenticate to parse server with your Firebase account
3+
4+
## How to use it?
5+
### 1) Install the module
6+
```js
7+
npm i -S parse-server-firebase-auth-adapter
8+
```
9+
### 2) Add environment variables
10+
* Copy the `firebaseAccountKey.json` from Firebase into your folder, maybe root of your project's folder.
11+
* Add new environment into your `.env` or using export in your terminal.
12+
```js
13+
// firebaseAccountKey.json store in root of project.
14+
FIREBASE_SERVICE_ACCOUNT_KEY = '../../firebaseAccountKey.json'
15+
16+
// URL for connect to Firebase database.
17+
FIREBASE_DATABASE_URL = "https://SOME_ID.firebaseio.com"
18+
```
19+
### 3) Add this module when creating `ParseServer`
20+
```js
21+
import { ParseServer } from 'parse-server'
22+
import firebaseAuthAdapter from 'parse-server-firebase-auth-adapter'
23+
...
24+
const parserServer = new ParseServer({
25+
...
26+
auth: {
27+
firebase: firebaseAuthAdapter
28+
}
29+
})
30+
```
31+
### 4) Using Firebase access token in our project
32+
* Get Parse access token by POST a raw data to `/parse/users`
33+
```sh
34+
curl -X POST \
35+
{{host}}/parse/users \
36+
-H 'content-type: application/json' \
37+
-H 'x-parse-application-id: {{ParseAppId}}' \
38+
-d '{
39+
"authData": {
40+
"firebase": {
41+
"access_token": "{{access_token}}",
42+
"id": "{{FirebaseUID}}"
43+
}
44+
}
45+
}'
46+
```

0 commit comments

Comments
 (0)