I had tried to access my FB token using the preliminary code shown by pablo over here :
https://github.com/pablobarbera/Rfacebook
However I get the following error message :
Error in callAPI(query, token) :
An active access token must be used to query information about the current user.
I used this code:
fb_oauth <- fbOAuth(app_id="14025", app_secret="5fdb6ef5776",extended_permissions = TRUE)
save(fb_oauth, file="fb_oauth")
load("fb_oauth")
I understand that I am not having access using my token despite authentication completion. Could someone please help.
Quick fix is just remove type = "application/x-www-form-urlencoded"
from fbOauth.R in RFacebook package. Because now Facebook returns response in JSON format.
Related
I am trying to implement a solution of signing in and retrieving data similar to this question. However, when I send my get request, and print the text, I get the following:
{
"errorCode" : "5011",
"errorMessage" : "SSO Request Failed, Session token is null.",
"errorMessageDetail" : null
}
How do I fix this issue?
My code:
with requests.Session() as s:
r1 = s.post(url1,data={'username':'user_name','password':'1234','rememberme':'true','userprofile':'true'})
r2 = s.get(url2, cookies=r1.cookies)
print(r2.text)
I was using the wrong URL
Perhaps, I have run into one of the complex issues listed here: How to login using requests in Python?
I'm trying to use the AzureR family of R packages to interact with Outlook through the Graph API. Using Microsoft365R I have the following code:
outl <- get_business_outlook(
tenant = tenant_id,
app = client_id,
password = client_secret
)
But this results in a 403 error:
Error in process_response(res, match.arg(http_status_handler), simplify) :
Forbidden (HTTP 403). Failed to complete operation. Message:
Insufficient privileges to complete the operation.
The app in question has the API permissions Mail.ReadWrite, Mail.ReadWriteShared, Mail.Send, Mail.Send.Shared, offline_access, openid, User.Read.
I also tried using the AzureGraph package directly like:
login <- create_graph_login(
tenant = tenant_id,
app = client_id,
password = client_secret
)
This works and I get a token. I then try to extract user information with me <- login$get_user(), but this throws the same 403 error as above. I suspect there is something I need to do to actually authenticate the user, but I can't really figure out what.
I am entirely new to the Graph API so it's very possible that I have missed something obvious. Any help appreciated!
Microsoft365R/AzureGraph author here. In the code you show, both with get_business_onedrive() and create_graph_login(), you are authenticating as the app, not as the user. This means that there is no user account involved, hence you're unable to view user details or send email.
To authenticate as the user, run
# Microsoft365R
get_business_outlook("tenant_id", app="client_id")
# AzureGraph
create_graph_login("tenant_id", app="client_id")
ie, without the password argument. You should know it's working if R opens up a browser window for you to login to Azure (or to show it's successfully logged in).
The latest revision of the AzureAuth package has a vignette that explains a bit more on the various authentication scenarios. AzureAuth::get_azure_token is the underlying function used to obtain an OAuth token by Microsoft365R and AzureGraph, and you can pass down the arguments mentioned in the vignette from get_business_outlook and create_graph_login.
I am fairly new to using APIs and trying to use the zendesk API now through R using the ZendeskR package. I belive I have connected to it however I keep getting the following error whenever I try to query it.
Here is my code:
library(zendeskR)
library(rjson)
zendesk(username, password, url)
ticket <- getTicket('20150')
The username, password and url are all variables that I have assigned the correct values.
The following error that I get when I run it is this:
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Please help as I am unsure on what this error means or what I am doing wrong.
Thanks.
TLS v1.1 is no longer accepted by Zendesk, please use TLS v1.2.
I am trying to fetch Gmail search results from Gmail API using an access token.
The following code works and returns an array of my email IDs:
fetch(`https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}`)
I then try to append a search query following the Gmail API documentation guidelines
fetch(`https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}?q=${text}`)
and it brings this error code: 401, message: 'Invalid Credentials'
Authentication scope is set to https://mail.google.com/ which assumes full control of the email. I tried swapping access_token and q parameters, as well as removing the access_token parameter but still no success. What am I doing wrong?
`https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}?q=${text}
you are preforming a HTTP GET in this call. Additional parameters are tacked on using a & only the first one starts with a ?
try this:
`https://www.googleapis.com/gmail/v1/users/${userId}/messages?access_token=${accessToken}&q=${text}
Until a month ago I was using the Rfacebook library with no problems. When I load the token I had generated and I want to use some function for example
getUsers("me",fb_oauth) #fb_oauth is my token
it gives me the following error:
Error in callAPI(url = url, token = token) :
Error validating access token: Session has expired on Tuesday, 04-Apr-17 13:24:59 PDT. The current time is Tuesday, 02-May-17 06:33:21 PDT.
To try to solve it I generate a new password in the app and generate a new token and I get the new token correctly:
fb_oauth <- fbOAuth(app_id="12345678", app_secret="xxxx")
Copy and paste into Site URL on Facebook App Settings: http://localhost:1410/
When done, press any key to continue...
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
But when I want to use the same function it gives me error
Error in callAPI(url = url, token = token) :
An access token is required to request this resource.
Also configure the login in the app but it does not work either
Anyone know how to generate the new token with the new 2.9 update?
Regards
As CBroe mentioned, the access token return format has changed and therefore the problem seems to be, that the credentials (including the access token) returned when authorizing with facebook is saved as the field name/key instead of the field value.
So a fix to this would be the following:
fb_oauth <- fbOAuth(app_id, app_secret, extended_permissions = FALSE,legacy_permissions = FALSE)
fb_oauth_credentials <- fromJSON(names(fb_oauth$credentials))
and then to make a request, such as getting a page would be;
fb_page <- getPage(page = "FBUserNameHere",
token = fb_oauth_credentials$access_token)