mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 23:32:27 -05:00
Add external API for sending SMS to openapi
This commit is contained in:
@@ -754,3 +754,13 @@ def create_admin_jwt():
|
|||||||
current_app.logger.error('Can only be run in development')
|
current_app.logger.error('Can only be run in development')
|
||||||
return
|
return
|
||||||
print(create_jwt_token(current_app.config['SECRET_KEY'], current_app.config['ADMIN_CLIENT_ID']))
|
print(create_jwt_token(current_app.config['SECRET_KEY'], current_app.config['ADMIN_CLIENT_ID']))
|
||||||
|
|
||||||
|
@notify_command(name='create-user-jwt')
|
||||||
|
@click.option('-t', '--token', required=True, prompt=False)
|
||||||
|
def create_user_jwt(token):
|
||||||
|
if getenv('NOTIFY_ENVIRONMENT', '') != 'development':
|
||||||
|
current_app.logger.error('Can only be run in development')
|
||||||
|
return
|
||||||
|
service_id = token[-73:-37]
|
||||||
|
api_key = token[-36:]
|
||||||
|
print(create_jwt_token(api_key, service_id))
|
||||||
|
|||||||
@@ -11,18 +11,28 @@ An API key can be created at https://notifications-admin.app.cloud.gov/services/
|
|||||||
|
|
||||||
## Using OpenAPI documentation
|
## Using OpenAPI documentation
|
||||||
|
|
||||||
### Retrieving a bearer token for use
|
### Retrieving a jwt-encoded bearer token for use
|
||||||
|
|
||||||
On a mac, run
|
On a mac, run
|
||||||
|
|
||||||
|
#### Admin UI token
|
||||||
|
|
||||||
```
|
```
|
||||||
flask command create-admin-jwt | tail -n 1 | pbcopy
|
flask command create-admin-jwt | tail -n 1 | pbcopy
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### User token
|
||||||
|
|
||||||
|
```
|
||||||
|
flask command create-user-jwt --token=<USER_API_TOKEN> | tail -n 1 | pbcopy
|
||||||
|
```
|
||||||
|
|
||||||
to copy a token usable by the admin UI to your pasteboard. This token will expire in 30 seconds
|
to copy a token usable by the admin UI to your pasteboard. This token will expire in 30 seconds
|
||||||
|
|
||||||
### Disable token expiration checking in development
|
### Disable token expiration checking in development
|
||||||
|
|
||||||
|
Because jwt tokens expire so quickly, the development server can be set to allow tokens older than 30 seconds:
|
||||||
|
|
||||||
```
|
```
|
||||||
env ALLOW_EXPIRED_API_TOKEN=1 make run-flask
|
env ALLOW_EXPIRED_API_TOKEN=1 make run-flask
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -441,3 +441,28 @@ paths:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/userObject"
|
$ref: "#/components/schemas/userObject"
|
||||||
|
/v2/notifications/sms:
|
||||||
|
post:
|
||||||
|
security:
|
||||||
|
- bearerAuth: []
|
||||||
|
description: 'Send an SMS message'
|
||||||
|
tags:
|
||||||
|
- external-api
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
phone_number:
|
||||||
|
type: string
|
||||||
|
template_id:
|
||||||
|
type: string
|
||||||
|
personalisation:
|
||||||
|
type: object
|
||||||
|
reference:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
description: Sent
|
||||||
|
|||||||
Reference in New Issue
Block a user