@@ -10,49 +10,49 @@ library(tmcrstudioaddin)
10
10
11
11
test_check(" tmcrstudioaddin" )
12
12
13
- response <- login(" a" , " b" , " c" , " d" , " tmc.mooc.fi" )
13
+ # response <- login("a", "b", "c", "d", "tmc.mooc.fi")
14
14
15
- login <- function (clientID , secret , username , password , serverAddress ) {
16
- body <- list (" grant_type" = " password" ,
17
- " client_id" = clientID ,
18
- " client_secret" = secret ,
19
- " username" = username ,
20
- " password" = password )
21
- # Authenticate
22
- url <- paste(serverAddress , " /oauth/token" , sep = " " )
23
- req <- httr :: POST(url = url ,
24
- body = body ,
25
- config = httr :: timeout(30 ),
26
- encode = " form" )
27
- # if http status is ok return token
28
- .dcat(" req" , req )
29
- # print(req)
30
- if (status_code(req ) == 200 ) {
31
- token <- paste(" Bearer" , httr :: content(req )$ access_token )
32
- credentials <- list (username = username ,
33
- token = token ,
34
- serverAddress = serverAddress ,
35
- organization = NULL )
36
- # print("saveCredentials site A")
37
- tmcrstudioaddin :: saveCredentials(credentials )
38
- response <- list (token = token ,
39
- error = NULL ,
40
- error_description = NULL )
41
- } else if (status_code(req ) == 400 ) {
42
- response <- list (token = NULL ,
43
- error = " Bad request" ,
44
- error_description = " Check your username and/or password" )
45
- } else if (status_code(req ) == 401 ) {
46
- response <- list (token = NULL ,
47
- error = " Invalid credentials" ,
48
- error_description = " Check your username and/or password" )
49
- } else {
50
- response <- list (token = NULL ,
51
- error = " Error" ,
52
- error_description = " Something went wrong. Try again later" )
53
- }
54
- return (response )
55
- }
15
+ # login <- function(clientID, secret, username, password, serverAddress) {
16
+ # body <- list("grant_type" = "password",
17
+ # "client_id" = clientID,
18
+ # "client_secret" = secret,
19
+ # "username" = username,
20
+ # "password" = password)
21
+ # # Authenticate
22
+ # url <- paste(serverAddress, "/oauth/token", sep = "")
23
+ # req <- httr::POST(url = url,
24
+ # body = body,
25
+ # config = httr::timeout(30),
26
+ # encode = "form")
27
+ # # if http status is ok return token
28
+ # .dcat("req", req)
29
+ # # print(req)
30
+ # if (status_code(req) == 200) {
31
+ # token <- paste("Bearer", httr::content(req)$access_token)
32
+ # credentials <- list(username = username,
33
+ # token = token,
34
+ # serverAddress = serverAddress,
35
+ # organization = NULL)
36
+ # # print("saveCredentials site A")
37
+ # tmcrstudioaddin::saveCredentials(credentials)
38
+ # response <- list(token = token,
39
+ # error = NULL,
40
+ # error_description = NULL)
41
+ # } else if (status_code(req) == 400) {
42
+ # response <- list(token = NULL,
43
+ # error = "Bad request",
44
+ # error_description = "Check your username and/or password")
45
+ # } else if (status_code(req) == 401) {
46
+ # response <- list(token = NULL,
47
+ # error = "Invalid credentials",
48
+ # error_description = "Check your username and/or password")
49
+ # } else {
50
+ # response <- list(token = NULL,
51
+ # error = "Error",
52
+ # error_description = "Something went wrong. Try again later")
53
+ # }
54
+ # return(response)
55
+ # }
56
56
57
57
.dcat <- function (name , x ) {
58
58
cat(paste0(" <" , name , " >\n " ))
0 commit comments