Description Usage Arguments Value See Also Examples
This function calls all the other authentication functions so you can quick start. Sacrifices customisation for speed.
1 2 | doAuthMacro(input, output, session, securityCode, client.id, client.secret,
type = "analytics", customScopes = NULL)
|
input |
Shiny input object. |
output |
Shiny output object. |
session |
Shiny session object. |
securityCode |
A unique session code, such as from createCode() |
client.id |
The client ID taken from the Google API Console. |
client.secret |
The client secret taken from the Google API Console. |
type |
Type of Google Authentication. c("analytics"). |
customScopes |
If not NULL, then a chacter vector of Google scopes to authenticate. |
For Analytics:
A named list. See example for uses in shinyServer().
Google Authentication Token needed for API calls.
Table of Google Analytics Profiles needed for rollupGA
.
It also outputs the link users need to click on to authenticate as output$AuthGAURL. Put this in your ui.r somewhere by using uiOutput("AuthGAURL")
For Analytics, the function will also create the outputs for an authentication menu.
The user needs to choose their Account, Web Property and View for the GA API to work.
The menu outputs are per the defaults of renderAuthDropdownRow
Also outputs a DataTable called 'output$GAProfile' for use in ui.r as renderDataTable('GAProfile')
Authentication macros renderAuthDropdownRow
and authDropdownRow
Other authentication functions: authReturnCode
;
createCode
;
shinygaGetTokenURL
;
shinygaGetToken
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 | ## Not run:
securityCode <- createCode()
shinyServer(function(input, output, session)){
## returns list of token and profile.table
## client info taken from Google API console.
auth <- doAuthMacro(input, output, session,
securityCode,
client.id = "xxxxx.apps.googleusercontent.com",
client.secret = "xxxxxxxxxxxx",
type = "analytics"
)
ga.token <- auth$token
profile.table <- auth$table
## call the token for API calls
gadata <- reactive({
rollupGA(GAProfileTable = profile.table(),
dimensions = 'ga:date',
start_date = '2014-03-13',
end_date = '2015-03-13'
metrics = 'ga:sessions',
ga = ga.token())
})
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.