I am developing a shiny app with oath2.0 (Azure Active Directory). The package AzureAuth is used for this purpose. The app is deployed to Azure cloud.
The app is in line with the snippet specified in the package vignette. Thus the snippet could be used as reproducible example with consideration of predefined azure infrastructure.
The ui section works well: the user is required to log in -> if the authentication is passed the user is redirected to the deployed app.
However, the trouble arises on server side of the app when it is required to get user info. The error is generated by get_azure_token(). I have used the same approach as in the server section of the snippet -> password = client_secret.
token <- AzureAuth::get_azure_token(
resource = c('https://management.azure.com/.default', 'openid')
,tenant = 'my_tenant_id'
,app = "my_app_id"
,password = client_secret
,auth_type = "authorization_code"
,auth_code = opts$code
,authorize_args = list(redirect_uri = redirect)
,version = 2
,use_cache = FALSE
)
The error is as follows:
[1] "start token generation ..."
Server did not provide a refresh token: you will have to reauthenticate to refresh.
Add the 'offline_access' scope to obtain a refresh token.
if i add ‘offline_access’ to the scope -> resource = c(‘https://management.azure.com/.default’, ‘openid’, ‘offline_access’) -> the error is changed to:
[1]"start token generation ..."
Warning: Error in as.vector: cannot coerce type 'environment' to vector of type 'character'
47: as.character.default
45: sprintf
40: server
3: runApp
2: print.shiny.appobj
1: <Anonymous>
Error in as.vector(x, "character") :
cannot coerce type 'environment' to vector of type 'character'
I have checked existing topics about get_azure_token() issues but found no clues about this error. I have posted the issue to AzureAuth issues with no response from developers so far.
I would be grateful for your hints about this issue. Maybe, you could recommend other packages or approaches (escpecially with example).
1