-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathoauth-providers.Rmd
More file actions
86 lines (62 loc) · 2.8 KB
/
Copy pathoauth-providers.Rmd
File metadata and controls
86 lines (62 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: "Oauth Providers"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{oauth-providers}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
You might have already browsed the [guide on social sign in](social.html). They are in fact convenience wrapper to the more general "Oauth providers" class. It works in a very similar fashion and can even prove more convenient.
## R Package
First, instantiate the authentication from `FirebaseOauthProviders`, then define the provider you want to use with `set_provider`, finally `launch` whenever you want.
Below we have the authentication launch at the click of a button. We provide Microsoft by simply setting `microsoft.com` as provider. All that is needed to change to say Yahoo! is to change the provider to `yahoo.com` for instance.
```r
library(shiny)
library(firebase)
ui <- fluidPage(
useFirebase(),
actionButton("signin", "Sign in with Microsoft", icon = icon("microsoft")),
plotOutput("plot")
)
server <- function(input, output, session){
f <- FirebaseOauthProviders$
new()$
set_provider("microsoft.com")
observeEvent(input$signin, {
f$launch()
})
output$plot <- renderPlot({
f$req_sign_in()
plot(cars)
})
}
shinyApp(ui, server)
```
## Console Setup
The R-side of things is rather easy so here we briefly explain how to integrate those oauth providers with the Firebase console.
### Yahoo
For Yahoo it is fairly straightforward. Open you console under "Sign-in method" tab and enable Yahoo! as show below.

To get the necessary app ID and app secret visit [this link](https://developer.yahoo.com/apps/create/) and create an app
<div class="alert alert-warning">
<h4>Important</h4>
<p style="color:white;">Make sure you enter the "Redirect URI(s)" given to you by Firebase which resembles `https://my-application.firebaseapp.com/__/auth/handler` and tick the `OpenID Connect Permissions` at the bottom.</p>
</div>
On the resulting screen copy the app ID and secret to your Firebase console.
### Microsoft
Authenticating via Microsoft is handled by Microsoft Azure, create a free account if you do not have one the:
1. Visit [the portal](https://portal.azure.com/)
2. Search and select "Azure Active Directory"
3. In the left sidebar under "Manage" select "App registrations"
4. Then click <i class="fa fa-plus"></i> New registrations
5. Under "Redirect URI" select "Web" and place the redirect URL given by Firebase
6. Once created, on the "overview" screen copy the "Application (client) ID" to Firebase
7. The visit "Certificates & secrets" in the sidebar
8. Create a "New client secret" and copy it to Firebase
Once this done give Microsoft 2 minutes to sync before trying the authentication.