I am new to SalesForce and Heroku platform. I am trying to explore and learn as much as possible.
I have developed React app and deployed to Heroku. Its working as expected, but I am at a stage where I am suppose to make Rest API call to Salesforce and get data from SalesForce Object.
I tried jsforce, nforce plugins to connect to Salesforce and fetch data. But unable to.
I used Postman to connect to SalesForce, I am able to connect. But I am getting error when I am trying to connect to Salesforce through code stating (400 bad request).
I have enable CORS on my environment (sandbox). Please let me know if I am missing some configuration settings, it will be really helpful.
var org = nforce.createConnection({
clientId:
"3MVG9sLbBxQYwWqvgNjn4MAlHFib10UPpW1IV7IDsN55vY7xaljuzUxvnsVrk",
clientSecret:
"F762DF566D8B29455F54EC8176CBC19C54CBE953517AC",
redirectUri: "https://www.google.com/",
environment: "sandbox",
mode: "single",
autoRefresh: true
});
let creds = {
username: username,
password: password + securityToken
};
org.authenticate(creds, function(err, resp) {
if (!err) {
console.log("Access Token: " + resp.access_token);
oauth = resp;
} else {
console.log(err);
}
});
And below is the error which I am getting:
Related
I am getting 504 Bad Gateway Timeout error in responce but data gets inserted sucessfully to the databse.
Code executes perfectly locally with response time within 1.15s but whenever deployed to lambda it start giving this Timeout Error.
Node js Endpoint Route is as Follows
route.post("/Register", async (req, res) => {
try {
const user = new userschema({
Name: req.body.Name,
Email: req.body.Email,
UserName: req.body.UserName,
PhotoUrl: req.body.PhotoUrl,
});
await user.save();
return res.status.send("Created");
} catch (error) {
return res.status(500).send("Something Went Wrong");
}
});
I have Deployed Nodejs backend to aws lambda which is running in a VPC and using mongodb atlas it follow this architecture
I am new to aws so i followed This Youtube Video.
Data gets inserted to mongodb atlas Database sucessfully. So the Vpc Peering conncetion beetween lambda function and Mongodb Atlas must be all right.
Cloudwatch Logs is as Follows
I tried everything i could but still facing this issue.
I am working on Google Cloud Search API to search documents stored in Google Drive. I have Google Workspace account and few documents stored in Google Drive. I am able to search using Google Cloud search console but facing issue using below node.js code for searching using API.
Issue: I am able to generate the access token but get below error for search query:
Error: This project doesn't have Cloud Search's Query API Enabled,
and/or the Cloud Search Platform license has not been assigned to the
user account calling the Query API
var {google} = require("googleapis");
var serviceAccount = require('C:/nodejstest/key/serviceAccountKey.json');
// Specify the required scope.
var scopes = [
"https://www.googleapis.com/auth/cloud_search",
"https://www.googleapis.com/auth/cloud_search.query"
];
var jwtClient = new google.auth.JWT({
email: serviceAccount.client_email,
key: serviceAccount.private_key,
scopes: scopes,
subject: 'sample#example.com'
});
// Use the JWT client to generate an access token.
jwtClient.authorize(function(error, tokens) {
if (error) {
console.log("Error making request to generate access token:", error);
} else if (tokens.access_token === null) {
console.log("Provided service account does not have permission to generate access tokens");
} else {
var accessToken = tokens.access_token;
console.log('accessToken= ' + accessToken)
// Include the access token in the Authorization header.
}
});
const service = google.cloudsearch({version: 'v1'});
service.query.search({
auth: jwtClient,
requestBody: {
requestOptions: {
searchApplicationId: 'searchapplications/default',
debugOptions:{enableDebugging: true}
},
query: 'My query'
}
}).then((res) => {
console.log(JSON.stringify({results:res.results.length}));
console.log(JSON.stringify({resultsInfo:res.results[0]}));
}).catch((err) => {
console.error('Unexpected error with cloud search API.');
console.error(err.toString());
});
In above code I am passing workspace admins email id as subject.
I followed steps mentioned at below link
Configure access to the Google Cloud Search REST API
Perform Google Workspace domain-wide delegation of authority
Go to the google console then select the your project.
Then search for Cloud Search API then enable it.
Also make sure that your service account have access on Cloud Search Indexing API
I created a simple PowerApps Component Framework using the pac pcf init command.
After successfully packaging and importing this skeleton PCF application to my demo tenant I tried to add MSAL authentication to it.
I used the #azure/msal npm package to write a typescript configuration and login without adding React or Angular npm packages. I only used #azure/msal and package added during the pcf create process.
The final goal was to use the token received from the msal authentication make a request on a authorized method in my Wep Api.
The problem is that my Web Api is not located in my demo tenant and the user that is used for msal authentication is from the demo tenant and does not exist on the tenant of my Web Api.
I cannot change the login user in the popup window as it only displays the error message, and the guest user that was added to the demo tenant, that has access to the Web API cannot have Certificates added to it through portal azure or portal office admin center pages.
This is my login configuration(I will omit the tenant names and client id for the work tenant):
import { AuthenticationParameters, Configuration, UserAgentApplication } from '#azure/msal';
import { AuthOptions, CacheOptions, FrameworkOptions } from "#azure/msal/lib-commonjs/Configuration";
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
{
// Add control initialization code
const auth: AuthOptions = {
clientId:'clientid',
authority:'https://login.microsoftonline.com/tenantid',
redirectUri:'redirect uri',
validateAuthority: true
};
const cache: CacheOptions = {
cacheLocation:"localStorage"
};
const framework: FrameworkOptions = {
protectedResourceMap: new Map([
['web api url',['https://tenantid/clientid/uniquename (scope)']],
['CRM work sandbox',['CRM work sandbox user impersonation permission(scope)']]
]),
unprotectedResources:[]
};
const config: Configuration = {
auth: auth,
cache: cache,
framework: framework
};
const params: AuthenticationParameters = {
authority: 'https://login.microsoftonline.com/tenantid',
scopes:['offline_access',
'https://tenantid/clientid/uniquename(scope)',
'CRM work sandbox user impersonation permission(scope)'],
redirectUri:'web api redirect uri'
};
const userAgentApplication = new UserAgentApplication(config);
const login = userAgentApplication.loginPopup(params).then(data => {
console.log(data);
let user = userAgentApplication.getAccount();
console.log(user);
if (user) {
// signin successful
console.log('success');
} else {
// signin failure
console.log('fail');
}
}, function (error: string) {
// handle error
console.log('Error' + error);
});
}
The error message displayed:
AADSTS50177: User account 'user name' from identity provider
'https://sts.windows.net/guid/' does not exist in tenant 'name'
and cannot access the application 'client id'(name of registered
app in portal azure) in that tenant. The account needs to be
added as an external user in the tenant first. Sign out and
sign in again with a different Azure Active Directory user account.
Is there a way to test this without adding the pcf or account in my work tenant ?
our clients have authorised on website using firebase.auth.GoogleAuthProvider with drive scope.
I have sent the credential, accessToken, idToken to server side(JAVA).
this is the code on
my app.js
firebase.auth().signInWithPopup(googleAuthProvider).then(function (result) {
console.log(result);
$scope.authOnServerSide(result.credential);
}).catch(function (error) {
console.log(error);
});
I have followed "Authenticate with a backend server" tutorial, using GoogleIdTokenVerifier on server side and got GoogleIdToken object.
this is the code on my spring boot application
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport, jsonFactory)
.setAudience(Collections.singletonList(googleAuthClientId))
.build();
GoogleIdToken googleIdToken = verifier.verify(googleAuthorizationDTO.getIdToken());
My question is, how to use this GoogleIdToken/accessToken to make operations such as create file on that user's google drive, thanks
I found the answer.
GoogleCredential credential = new GoogleCredential();
credential.setAccessToken(googleAuthEntity.getAccessToken());
Drive drive = new Drive.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(), credential).build();
Issue Description
Migrated from Parse.com to Parse Server (Sashido hosting). Whenever I deploy my cloud code, I had to logout and login on the client app (iOS) to get results. Without re-logging in, I get empty results. The session token on the client side matches with DB. My request.user prints correctly. Only the queries are not working, no session errors but empty results (array or object). This happens to all queries and it was working fine in Parse.com platform. I have ACLs defined for each row and ACL in request.user is also correct but still no results.
Steps to reproduce
Client iOS code
let configuration = ParseClientConfiguration {
$0.applicationId = PARSE_APPLICATION_ID
$0.clientKey = PARSE_CLIENT_KEY
$0.server = PARSE_SERVER_URL
$0.localDatastoreEnabled = true
}
Parse.initializeWithConfiguration(configuration)
PFUser.enableRevocableSessionInBackground()
Server
Parse.Cloud.define("getPastWalks", function(request, response) {
console.info("user:: " + JSON.stringify(request.user) + JSON.stringify(request.params));
var fromDate = request.params.fromDate;
var toDate = request.params.toDate;
var walk = Parse.Object.extend("Walk");
var pastWalksQuery = new Parse.Query(walk);
pastWalksQuery.greaterThanOrEqualTo("dateAndTime", fromDate);
pastWalksQuery.lessThanOrEqualTo("dateAndTime", toDate);
pastWalksQuery.descending("dateAndTime");
pastWalksQuery.include("service");
pastWalksQuery.limit(request.params.limit);
pastWalksQuery.find().then(function(walks) {
console.info("past walk:: " + JSON.stringify(walks));
response.success(walks);
}, function(error) {
response.error(error);
})
});
Expected Results
The above code should retrieve 'all walks for that particular request.user'.
Actual Outcome
But I am getting empty array. When I logout and login, new session token is generated and it works. Without re-logging, no session token errors, only empty array.
Environment Setup
Server
parse-server version : 2.2.25-1
Localhost or remote server? : Sashido Hosting
Database
MongoDB version: -
Localhost or remote server? : Sashido Hosting
I had to pass sessionToken in the query
pastWalksQuery.find({sessionToken: request.user.getSessionToken()})
https://github.com/ParsePlatform/parse-server/issues/3456