Skip to content

Commit

Permalink
Add authentication documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed May 4, 2015
1 parent a40ae8d commit 4a75392
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ kreait_firebase:
main:
scheme: https
host: prefix-suffix-1234.firebaseio.com
secret: <your firebase secret>
references:
users: data/users
images: data/images
Expand Down Expand Up @@ -90,3 +91,26 @@ $firebase = $this->container->get('kreait_firebase.connection.main');
```php
$users = $this->container->get('kreait_firebase.reference.users');
```

### Authentication

To use authentication, you have to include the firebase token generator into your project

```
composer require firebase/token-generator
```

You also need to set the Firebase secret in your configuration.

Then, in your code, you can authenticate a request like this:

```php
$firebase = $this->container->get('kreait_firebase.connection.main');
$tokenGenerator = $firebase->getConfiguration()->getAuthTokenGenerator();

$adminToken = $tokenGenerator->createAdminToken();

$firebase->setAuthToken($adminToken);
```

This procedure is quite cumbersome at the moment, but will be made more conveniant in an upcoming release.

0 comments on commit 4a75392

Please sign in to comment.