Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wallasfaria/rails_firebase_auth
Exemplo de autenticação de api rails com Firebase
https://github.com/wallasfaria/rails_firebase_auth
Last synced: 21 days ago
JSON representation
Exemplo de autenticação de api rails com Firebase
- Host: GitHub
- URL: https://github.com/wallasfaria/rails_firebase_auth
- Owner: WallasFaria
- Created: 2020-06-16T16:35:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T21:52:21.000Z (almost 2 years ago)
- Last Synced: 2024-11-19T06:00:12.017Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rails Firebase Auth
Exemplo de autenticação de api rails com Firebase
## Setup
- Roda script de setup do rails
```sh
bin/setup
```- Copia o arquivo `.env.template` para `.env`
```sh
cp .env.template .env
```- Configura a variável de ambiente `FIREBASE_PROJECT_ID` no arquivo `.env`
- Roda tarefa para gerar certificado do firebase
```sh
rails firebase:certificates:request
```## Rodando o projeto
```sh
rails s
```## Usando authenticação
Após o usuário criar conta ou autenticar com firebase no frontend web ou mobile,
basta fazer as requisições para api passando o token do firebase.Exemplo:
__Get user profile__
> GET /profile
```sh
curl -X GET 'http://localhost:3001/profile' -H 'Authorization: Bearer user-token'
```retorno:
```json
{
"id": 1,
"name": "Wallas Faria da Silva",
"email": "[email protected]",
"phone": null,
"auth_id": "k5LWaAsas4544hhpl7ASIH9nm282",
"auth_provider": "google.com",
"created_at": "2021-01-25T00:51:41.055Z",
"updated_at": "2021-01-25T00:51:41.102Z",
"avatar_url": "http://localhost:3001/rails/active_storage/representations..."
}
```__Update user profile__
> PUT /profile
```sh
curl -X PUT 'http://localhost:3001/profile' \
-H 'Authorization: Bearer user-token' \
-H 'Content-Type: application/json' \
-d '{ "phone": "+5522556644998" }'
```retorno:
```json
{
"id": 1,
"phone": "+5522556644998",
"name": "Wallas Faria da Silva",
"email": "[email protected]",
"auth_id": "k5LWaAsas4544hhpl7ASIH9nm282",
"auth_provider": "google.com",
"created_at": "2021-01-25T00:51:41.055Z",
"updated_at": "2021-01-25T01:08:00.213Z",
"avatar_url": "http://localhost:3001/rails/active_storage/representations/..."
}
```