Authentication Error while connecting outlook from R - r

I m trying to connect to outlook from R
But it returns authentication error:
Error in response_error_handling(e$message[1]) :
Login denied: the server returned an authentication error
Please help
library(mRpostman)
con <- configure_imap(url="imaps://outlook.office365.com/",
username="*********#*******.com",
password=rstudioapi::askForPassword())
con$select_folder(name = "Inbox")

When it comes to Office 365, the email you see is usually an alias and not your "real" email address. For example, we use Office 365 in my company and my email is allan#company.com. However, the real address is 3254339#company.com, where 3254339 is my ID number in the company.
Please, check with your IT department/sector if this is also your case, and create ​the connection token like this
con <- configure_imap(
​url = "imaps://outlook.office365.com/",
​username = "3254339#company.com",
​password = rstudioapi::askForPassword()
)

Related

Connecting to Azure Data Lake by R using SAS Token

I am trying to connect to Azure DataLake Gen2 via R. I get from Azure DataLake administrator read access to given folder.
I have:
blob_service = 'https://DataLakeName.blob.core.windows.net'
data_lake_storage = 'https://DataLakeName.dfs.core.windows.net'
pathToFolder = 'path/to/folder/with/acess'
blob_sas_token = 'blobksastoken1232133210'
blob_sas_url = 'blob_service/pathToFolder?blob_sas_token'
Accoring to information about library AzureStor I tried:
library(AzureStor)
end_point <- blob_endpoint(endpoint = "https://DataLakeName.blob.core.windows.net/", sas = blob_sas_token)
list_blob_containers(end_point)
Unfortunately I got HTTP status code 500, what means probably an internal server error. Administratior said that token is correct and endpoint also works fine.
Error in process_storage_response(response,
match.arg(http_status_handler), : Internal Server Error (HTTP
500). Failed to complete Storage Services operation. Message:
InternalError Server encountered an internal error. Please try again
after some time.
Any idea what I am doing wrong, or how can I connect to ADL in other way using data that I have?

Error in Oauth2.0 authentication in R using HTTR (failed to connect: connection refused)

I am trying to create a simple app (in R) using GroupMe's API, which utilizes OAuth2.0. The documentation can be found here. However, I'm getting stuck on the first step of authentication/token generation for a user. See below for my code and the response I get:
access_key = ****
client_id = ****
gendpoint <- oauth_endpoint(
authorize = glue("https://oauth.groupme.com/oauth/login_dialog?client_id={client_id}"),
access = glue("http://localhost:1410/?access_token={access_key}")
)
gapp <- oauth_app(
"pingme",
key = client_id,
secret = access_key
)
t <- oauth2.0_token(
endpoint = gendpoint,
app = gapp
)
The above code is sufficient to bring in the login page, which presumably allows me to enter my credentials to obtain a token. However, when I enter my credentials, I get the following error message in R:
Authentication complete.
Error in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to localhost port 1410: Connection refused
So it looks like my authentication/login credentials worked, but somewhere an error prevented me from actually generating the token.
Could someone help me with this? This is my first time using the OAuth2.0 framework so I'm very confused. Thanks in advance!

How to connect R to Clickhouse?

I am new to Clickhouse and am experiencing difficulties connecting R to Clickhouse.
con <- DBI::dbConnect(RClickhouse::clickhouse(),host="srv-clickhouse",username="user",
password="pw")
This returns the error
Error in connect(config[["host"]], strtoi(config[["port"]]), config[["db"]], :
DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name
There definitely has to be a user by that name and password which leads me to believe that I've done something wrong while at the same time I'm not sure what I have to put into the host part of the address, nor the port nor in the beginning. Should I add the full URL to the host part? Right now I'm using RClickhouse but my database uses the port 8123. Is there any kind of proper documentation and how to solve this issue?
Thanks

What `control` settings are valid to send automated emails from Outlook using `sendmailR`?

EDIT: I found a solution. You can find it here. I had to resort to using mailR. I could never get sendmailR to work with the Office 365 services.
I am trying to send a single email using library(sendmailR) to later send daily automated emails to about 500 people. Unfortunately, I'm suck in step 1.
It is vital that I send these emails from my institution's Outlook account. I have no idea what control settings to use in order to successfully send mails from Outlook. I checked a couple of questions but they are either using the gmail SMPT server or they do not specify the control = ... settings they used. For example:
Use sendmailR with Windows
Sending an email from R
This is what I'm working with:
from <- "<myaccount#institution.org>"
to <- "<boss#institution.org>"
subject <- "Hello from R"
body <- list("It's working.")
sendmail(from, to, subject, body,
control = list(smptServer = "oultook.office.365", port = 443))
And I'm getting the following error message:
Error in wait_for(code) :
SMTP Error: 5.7.57 SMTP; Client was not authenticated to send anonymous mail
during MAIL FROM [SN4PR0501CA0061.namprd05.prod.outlook.com]
I believe I'm not specifying the port correctly. The sendmaiLR documentation is not specific enough, but something tells me I should be writing the port as "port 443"or something along those lines.
Does anyone know what controlsettings I should be using?

Failed to authenticate credentials using Mongolite R

I use R and trying to use the very recent "Mongolite". However I cannot connect to MongoDB server.
The manual clearly states the following:
mongo(collection = "test", db = "test", url = "mongodb://localhost")
This is what I have tried without success, where I have a log token and the port of course.
mongodb://heroku:TOKEN#lennon.mongohq.com:PORT
and keep getting the following error:
Error in mongo_collection_new(url, db, collection) :
Failed to authenticate credentials.
It is tried and true that mongolite (v0.7 as of today) supports authenticated connection to a remote 3.2.x MongoDB (as opposed to localhost).
The example below jeroenooms provides himself worked:
library(mongolite)
mongo(collection = "mtcars", url = "mongodb://readwrite:test#ds043942.mongolab.com:43942/jeroen_test")
To explain:
mtcars is the name of the MongoDB "collection" (or "table" if you insist). It could be a name that does not exist yet.
readwrite is the user name of your mongodb
test is the password of the user "readwrite"
ds043942.mongolab.com is the remote host, which could be replaced by ip address, i.e. 23.20.234.21
43942 is the port number. By default in MongoDB, it is 27017
jeroen_test is the name of the database instance in use, which has to exist already
Running the commands above in R will print:
Mongo Message: SCRAM: authenticating "readwrite" (step 1)
Mongo Message: SCRAM: authenticating "readwrite" (step 2)
Mongo Message: SCRAM: authenticating "readwrite" (step 3)
Mongo Message: SCRAM: "readwrite" authenticated
...
I tried to replace it with my own remote host info. It didn't work in the beginning, which turned to be the user role issue rather than mongolite issue. After ensuring a user with correct readWrite roles, I connected to my remote 3.2.x MongoDB via mongolite package.
The following 2 sources were of great help to me in setting up users in MongoDB:
enable-authentication
Manage User and Roles
If you look into the source code of jeroenooms/mongolite you can see that it doesn't support authentication yet:
https://github.com/jeroenooms/mongolite/blob/master/R/mongo.R
mongo_collection_new <- function(uri = "mongodb://localhost", db = "test", collection = "test"){
stopifnot(is.character(uri))
stopifnot(is.character(db))
stopifnot(is.character(collection))
.Call(R_mongo_collection_new, uri, db, collection)
}
just change the order :
mongo( url = "mongodb://localhost",db = "test",collection = "test")
I found that the following command allowed me to connect to mongodb using mongolite and the legacy SCRAM-SHA-1 authentication mode.
library(mongolite)
mongoUrl <- "mongodb://a_username:a_password#localhost:27017/admin" #<-admin here is the mongodb database that stores the authentication info
# specify your collection
colname <- "a_collection"
# specify your database
dbname <- "a_database"
# create connection (con)
con <- mongo(collection = colname, url = mongoUrl, db=dbname)
# count how many records (fyi this is just a test)
con$count('{}')

Resources