So I have implemented the react native FBSDKGraphRequest and login button. Login is working correctly, but when i attempt a graph request of the user, instead of the complete object i expect the /me endpoint to return
{
"id": "162036280799349",
"birthday": "08/08/1980",
"email": "test_ppjeffg_eight\u0040tfbnw.net",
"first_name": "Test",
"gender": "male",
"last_name": "Eight",
"link": "https://www.facebook.com/app_scoped_user_id/162036280799349/",
"locale": "en_US",
"name": "Test Eight",
"timezone": -8,
"updated_time": "2015-07-28T18:22:16+0000",
"verified": false
}
I just get
Object {name: "Test Eight", id: "162036280799349"}
I very well may be doing the request incorrectly, though I've done everything according to documentation. Here is the relevant source code:
class LoadingOverlay extends BaseComponent{
constructor(props){
super(props);
this._bind(/*'_fetchFriendsRequestFunction'*/);
this.state = {isVisible: true,
token: null,
profileInfo: null}
}
_fetchGraphRequestFunction(){
console.log("start");
var fetchProfileRequest = new FBSDKGraphRequest((error, result) => {
if (error) {
alert('Error making request.');
} else {
// Data from request is in result
console.log(result);
}
}, '/me');
// Start the graph request.
fetchProfileRequest.start();
}
render(){
return(
<Overlay isVisible={this.state.isVisible}>
<BlurView style={styles.background} blurType="dark">
<FBSDKLoginButton
onLoginFinished={(error,result)=>{
if (error){
alert('Error Logging In.');
} else {
if (result.isCanceled){
alert('Login Cancelled.');
} else {
FBSDKAccessToken.getCurrentAccessToken((token)=>{
console.log(token.tokenString);
this._fetchGraphRequestFunction();
})
}
}
}}
onLogoutFinished={()=>console.log('Logged Out.')}
readPermissions={['public_profile', 'email', 'user_birthday', 'user_friends']}
publishPermissions={['publish_actions']}/>
</BlurView>
</Overlay>
);
}
}`
You can request additional parameters from Facebook by either appending them to the uri like this:
/me?fields=id,name,email
or by calling the addStringParameter function on the FBSDKGraphRequest object like this:
fetchProfileRequest.addStringParameter('picture,email,gender','fields');
However, what fields you get in return depends on the permission of your app and the settings of the user.
Also, note this little trick from the ios FB sdk documentation: https://developers.facebook.com/docs/reference/ios/current/class/FBSDKLoginButton/
Note, that if read permissions are specified, then publish permissions should not be specified.
So try sending an empty publishPermissions parameter and see if that fixed it.
More information here:
Publish or manage permissions are not permited to to be requested with read permissions FACEBOOK SDK
https://coderwall.com/p/gkeqcq/request-read-and-publish-permissions-simultaneously-using-ios-facebook-support
I'd love to see an example of the flow to make this work in react native if anyone has it.
Related
I have been trying to connect an assistant action to my backend server
I am using my own Oauth server and followed the instructions on
https://developers.google.com/actions/identity/oauth2?oauth=code
I am using actions_intent_Sign_in for my dialogflow event intent (like https://actions-on-google.github.io/actions-on-google-nodejs/classes/conversation_helper.signin.html)
when i use my action to sign in, i get the login window to my server, i do the account linking and i can see that i generated the tokens on my server but i cant find the token in (conv.user.access.token)
and this is the code for my intent using "actions on google sdk "
'use strict';
var _ = require('lodash');
var path = require('path')
var express = require('express')
var http = require('http')
const bodyParser = require('body-parser');
var expressApp = express().use(bodyParser.json());
var server = http.createServer(expressApp).listen(3000)
const {
dialogflow,
SignIn
} = require('actions-on-google');
const app = dialogflow({
debug: true,
clientId: '7b4a6dfc-4b35-11e9-8646-d663bd873d93'
});
app.intent('Start Sign-in', conv => {
conv.ask(new SignIn());
});
app.intent('Get Sign-in', (conv, params, signin) => {
console.log("get sign in ");
console.log(JSON.stringify(signin));
if (signin.status === 'OK') {
const access = conv.user.access.token
console.log("the access token is " + access);
conv.ask('Great, thanks for signing in! What do you want to do next?');
} else {
conv.ask('I wont be able to save your data, but what do you want to do next?.');
}
});
and the response comes back as
{"#type":"type.googleapis.com/google.actions.v2.SignInValue","status":"OK"}
the access token is undefined
Response {
"status": 200,
"headers": {
"content-type": "application/json;charset=utf-8"
},
"body": {
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Great, thanks for signing in! What do you want to do next?"
}
}
]
}
}
}
}
}
the user object of conv has only this data
"user": {
"raw": {
"lastSeen": "2019-03-20T12:46:23Z",
"locale": "en-US",
"userId": "okdhyeGSk5tofgLjEepIUrA6mmewCESY8MjklZRPvQJgv6-uybfPobwdfgtrGZJ3bE2sM9ninhst"
},
"storage": {},
"_id": "okdhyeGSk5tofgLjEepIUrA6mmewCESY8MjklZRPvQJgv6-uybfPobwdfgtrGZJ3bE2sM9ninhst",
"locale": "en-US",
"permissions": [],
"last": {
"seen": "2019-03-20T12:46:23.000Z"
},
"name": {},
"entitlements": [],
"access": {},
"profile": {}
}
i dont know where the access/refresh token can be found or if there is any requirement for the post to send from my oauth server that i missed
so finally i managed to get it working with the help of Actions on Google Support Team
the problem was me having another google account logged-in in another tab, even though i had the AoG and dialogflow agent connected with the same account
tried all using incognito window and it works
I need to add the Firestore document id to the user document but after Googling for the past couple of hours I am none the wiser. The code I use to create the document follows:
try {
String userId =
await auth.createUserWithEmailAndPassword(_email, _password);
await addDocument('Countries/AU/user', {
"userId": userId,
"email": _email,
"password": _password,
"givenName": _givenName,
"familyName": _familyName,
"mobile": _mobile,
"phone": _phone,
"companyName": _companyName,
"language": _language,
"documentId": _documentId
});
} catch (e) {
print('Error: $e');
}
I then need retrieve it later when updating it by
Firestore.instance.collection('Countries/AU/user').
document(_documentid).get().then((docSnap){
...
}
I tried adding "DocumentReference docRef" in front of "await addDocument('Countries/AU/user'," but it caused a syntax error. There are other "reference number" type suggestions but none worked. I hope someone is able to help me. I have also tried "print(document.documentID)"
Microsoft Graph sometimes returns a strange result
Client Error:
GET https://graph.microsoft.com/v1.0/me/calendars resulted in a 404 Not Found
{
"error": {
"code": "ErrorInvalidUser",
"message": "The requested user 'chrisb#domain_name.com' is invalid.",
"innerError": {
"request-id": "c229f76d-a9d0-4441-b663-b34f4996cddb",
"date": "2017-11-21T01:23:18"
}
}
}
That issue seems to be strange for me, since I know the user exists since I can login under it.
What I do:
I use stored refresh token to get access token.
Using that access token I try to get list of all user calendars.
At that point it return me fail message.
Question:
What does that error mean - since user is 100% present at Microsoft (I able to get auth token from refresh token and able to login under that user)
I had faced same issue for some MS users only whom specially has very old account, I was passing email of microsoft user like : following
let userInfo = {email: user.email}
let apiParams = {token: access_token, event: newEvent,calendarId: msUserInfo.calendarId, user:userInfo}
Solution:
After I had issue, I have remove 'user' parameter from api and it works for me.
I have set now as following.
I have used Node, node-outlook
const outlook = require('node-outlook');
let newEvent = {
"Subject": objUpdate.title,
"Body": {
"ContentType": "HTML",
"Content": objUpdate.description
},
"Start": {
"DateTime": moment('startDate').toISOString(),
"TimeZone": objUpdate.timeZone
},
"End": {
"DateTime": moment('endDate').toISOString(),
"TimeZone": objUpdate.timeZone
}
};
outlook.calendar.createEvent({token: access_token, event: newEvent ,calendarId: msUserInfo.calendarId
},async function(error, result){
if (error) {
console.log("error: -",error)
throw "Microsoft Calendar Api Err."
}else if (result) {
console.log("Result -")
}
});
I am trying to create a new issue utilizing the JIRA REST API and whenever I try, I get back the following generic error:
{ errorMessages: [ 'Internal server error' ], errors: {} }
I can successfully GET from the API, and the credentials I'm connecting with have full Admin access to JIRA (so it's not an Auth issue), but I get this error every time with POST. Below is a snippet of the JSON data I'm sending. Am I missing anything obvious?
Below is my JavaScript code. Note I'm using jira-connector from npm. (Real domain replaced with mydomain for this sample code)
const JiraClient = require('jira-connector');
const dotenv = require('dotenv').config();
function createNewIssue(fields) {
const encoded = process.env.JIRA_ENCODED_PW;
const jira = new JiraClient({
host: 'mydomain.atlassian.net',
basic_auth: {
base64: encoded
}
});
return new Promise((resolve, reject) => {
jira.issue.createIssue(fields, (error, issue) => {
if (error) {
console.log(error);
reject(error);
} else {
console.log(issue);
resolve(encoded);
}
});
})
}
Below is the JSON that's being passed into fields in the JS above. Note customfield_17300 is a radio button, and customfield_17300 is a multi-select box. For both cases, I've tried using the "id" and also the actual string "name" value. All IDs below were taken straight from a API GET of the same issue in question:
{
"fields": {
"project": {
"id": "13400"
},
"summary": "TEST API TICKET - 01",
"issuetype": {
"id": "11701"
},
"customfield_14804": { "id": "13716" },
"customfield_14607": "Hardware",
"customfield_17300": [
{
"id": "18322"
}
] ,
"customfield_16301": "Customer PO",
"customfield_14800": "LA, California",
"customfield_16302": "FEDEX 234982347g"
}
}
sigh I figured it out... other posts that said this cryptic error was due to a malformed JSON were correct.
In my route, I passed fields as coming from req.body.fields which actually dove into the fields values instead of passing it straight through. This made it so that when the JSON was sent to JIRA the fields outer wrapper was missing. I changed my route to pass along req.body instead of req.body.fields and all was well.
...that was a fun 4 hours...
I want to import all events from Google calendar. In my code I will authenticate user first. Once user is sign in successfully then I will call below API using GET request.
https://www.googleapis.com/calendar/v3/calendars/my Email/events?key=my App Key&fields=items(id,start,summary,status,end)
I am getting response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
Once I change my calendar as a public it will give all events details, but if calendar is mark as a private then it’s giving above response.
Any one having idea how to get events details from private calendar?
I think you may need add your access token to access your calendar information, if you use JavaScript library, you can take a look at these sample:
https://developers.google.com/api-client-library/javascript/features/authentication
I have implemented getCalendar using Angular JS + Ionic (using REST API)
https://developers.google.com/google-apps/calendar/v3/reference/
, but I am at work now, will send you later if you need it.
take a look at this example, you may understand how to attached yr request token to your request:
ionicExample.controller("DigitalOceanExample", function($scope, $http, $cordovaOauth) {
$scope.digitalOceanLogin = function() {
$cordovaOauth.digitalOcean("CLIENT_ID_HERE", "CLIENT_SECRET_HERE").then(function(result) {
window.localStorage.setItem("access_token", result.access_token);
}, function(error) {
console.log(error);
});
}
$scope.getDroplets = function() {
$http.defaults.headers.common.Authorization = "Bearer " + window.localStorage.getItem("access_token");
$http.get("https://api.digitalocean.com/v2/droplets")
.success(function(data) {
console.log(JSON.stringify(data.droplets));
})
.error(function(error) {
console.log(error);
});
}
});
I got the solution from this Google Developer console
LINK