Commit 3a99264e authored by Charles's avatar Charles
Browse files

Customize login portal

parent d9681359
[Link to auth0 package](https://curso-r.github.io/auth0/)
## Send API calls
To use the audience parameter and send API calls:
* Install the development version from Github.
* Find it in your Auth0 interface: Applications/APIs.
* Find the audience parameter in your Auth0 interface: Applications/APIs (Identifier).
* Add the value to your `_auth0.yml` file.
* Add the needed scopes in the `_auth0.yml` file. Keep `"openid profile"` at the minimum.
......@@ -26,6 +28,10 @@ request_user <- httr::GET(
jsonlite::fromJSON(rawToChar(request_user$content))
```
## Customize login form
* Enable your Application with the Management API in the Applications/APIs/Machine to Machine Applications interface.
* Grant the `read:prompts` and `update:prompts` permissions.
......
# Documentation: https://auth0.com/docs/brand-and-customize/text-customization-new-universal-login
# Fetch a token
response <- httr::POST(
url = paste0(
"https://",
Sys.getenv("AUTH0_USER"),
".eu.auth0.com/oauth/token"
),
body = paste0(
'{"client_id":"', Sys.getenv("AUTH0_KEY"),
'","client_secret":"', Sys.getenv("AUTH0_SECRET"),
'","audience":"https://', Sys.getenv("AUTH0_USER"), '.eu.auth0.com/api/v2/"',
',"grant_type":"client_credentials"}'
),
httr::add_headers(
`content-type` = "application/json"
),
encode = "raw"
)
token <- jsonlite::fromJSON(rawToChar(response$content))
# Read custom text
custom_text <- httr::GET(
url = paste0(
"https://",
Sys.getenv("AUTH0_USER"),
".eu.auth0.com/api/v2/prompts/login/custom-text/en"
),
httr::add_headers(
Authorization = paste(token$token_type, token$access_token),
`Content-Type` = "application/json"
)
)
jsonlite::fromJSON(rawToChar(custom_text$content))
# Send custom text
custom_text <- httr::PUT(
url = paste0(
"https://",
Sys.getenv("AUTH0_USER"),
".eu.auth0.com/api/v2/prompts/login/custom-text/en"
),
httr::add_headers(
Authorization = paste(token$token_type, token$access_token),
`Content-Type` = "application/json"
),
body = list(
login = list(
description = "Login to continue."
)
),
encode = "json"
)
jsonlite::fromJSON(rawToChar(custom_text$content))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment