Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jottenlips/vaporauthtemplaterequestexamples
💧 Sample requests and documentation for creating your first authenticated Vapor API 💧
https://github.com/jottenlips/vaporauthtemplaterequestexamples
api apple auth authentication basic-authentication bearer-tokens curl endpoints example paw postman protected-routes server server-side-swift swift users vapor vapor2 vapor3 xcode
Last synced: 4 days ago
JSON representation
💧 Sample requests and documentation for creating your first authenticated Vapor API 💧
- Host: GitHub
- URL: https://github.com/jottenlips/vaporauthtemplaterequestexamples
- Owner: jottenlips
- Created: 2018-08-10T17:30:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-19T22:30:57.000Z (almost 6 years ago)
- Last Synced: 2024-11-28T12:11:41.540Z (2 months ago)
- Topics: api, apple, auth, authentication, basic-authentication, bearer-tokens, curl, endpoints, example, paw, postman, protected-routes, server, server-side-swift, swift, users, vapor, vapor2, vapor3, xcode
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example requests for Vapor Auth Api template
## Make a new template
### Install vapor using brew`brew install vapor/tap/vapor`
### Make a new vapor authenticated api
https://docs.vapor.codes/3.0/auth/getting-started/
```
vapor new hello --auth
```
```
cd hello
```then
```
vapor build
```
```
vapor run
```
or
```
vapor xcode
```## Create user # VAPOR 3
```
curl -X "POST" "http://localhost:8080/users" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"name": "",
"email": "",
"password": "",
"verifyPassword = ""
}'```
## Login
```
curl -X "POST" "http://localhost:8080/login" \
-H 'Content-Type: application/json; charset=utf-8' \
-u 'myemail:mypassord' \
-d $'{}'
```returns `token` to be used for protected routes.
## Todo object
### get todo
```
curl "http://localhost:8080/todos?" \
-H 'Authorization: Bearer mytokenhere' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{}'
```### post todo
```
curl -X "POST" "http://localhost:8080/todos" \
-H 'Authorization: Bearer 0BMDp6YeOuH0qYYrXInDhA==' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"title": "Do the dishes"
}'
```
### delete todo
```
curl -X "DELETE" "http://localhost:8080/todos/1" \
-H 'Authorization: Bearer 0BMDp6YeOuH0qYYrXInDhA==' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{}'
```## Create user # VAPOR 2
### register
```
## i-register
curl -X "POST" "http://localhost:8080/users" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"name": "",
"email": "",
"password": ""
}'```
## Login
### login
```
curl -X "POST" "http://localhost:8080/login" \
-H 'Content-Type: application/json; charset=utf-8' \
-u 'myemail:mypassord' \
-d $'{}'
```returns `token` to be used for protected routes.
## Get protected data
### me
```
curl "http://localhost:8080/me?" \
-H 'Authorization: Bearer mytokenhere' \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{}'
```