Open billnbell opened 1 year ago
Any update on this?
I was able to get it to work. We really should document it.
const callbackUrl =
appEnv === 'PROD'
? 'https://login.salesforce.com/services/oauth2/authorize'
: 'https://sandboxname.sandbox.my.salesforce.com/services/oauth2/authorize';
const scopes = ['api', 'web', 'refresh_token']; // must match in connected apps in SF, redirect and secrets must match too
let config: AuthConfiguration = {
issuer: callbackUrl, // see above
clientId: consumerKey, // get from SF
clientSecret: consumerSecret, // get from SF
redirectUrl, // must be registered in app, and setup in SF
scopes, // must match to SF
serviceConfiguration: {
authorizationEndpoint: callbackUrl,
tokenEndpoint:
appEnv === 'PROD'
? 'https://login.salesforce.com/services/oauth2/token'
: 'https://sandboxname.sandbox.my.salesforce.com/services/oauth2/token',
revocationEndpoint:
appEnv === 'PROD'
? 'https://login.salesforce.com/services/oauth2/revoke'
: 'https://sandboxname.sandbox.my.salesforce.com/services/oauth2/revoke',
},
};
Ok then when setup call:
const result = await authorize(config);
console.log(result);
if (result) {
const { refreshToken, accessToken, tokenAdditionalParameters } = result;
console.log(`refreshToken: ${refreshToken} accessToken: ${accessToken}`);
}
Also if you want for force login - like after clicking logout button - add to the config.
config = { ...config, additionalParameters: { prompt: 'login' } };
OK no idea but I am getting on Android: JSON deserialization error
OK for Android you cannot have issuer and serviceConfiguration.
It works fine with issuer. Just give it the main URL like "https://login.salesforce.com" or "https://sandboxname.sandbox.my.salesforce.com"
let config: AuthConfiguration = {
issuer: salesforceIssuerUrl,
clientId: consumerKey,
clientSecret: consumerSecret,
redirectUrl,
scopes,
};
How do you setup salesforce with this?