I am using in my Meteor application Slack package: acemtp:accounts-slack and Sign in with Slack button. Unfortunately I am getting an error and cannot login. I am getting following error in console:
"No matching login attempt found",
errorType: "Accounts.LoginCancelledError"
Button redirects me to the following link: https://slack.com/oauth/authorize?client_id=188243231058.189281460071&response_type=code&scope=identity.basic,identity.email,identity.avatar&redirect_uri=http://localhost:3000/_oauth/slack?close&state=eyJsb2dpblN0eWxlIjoicG9wdXAiLCJjcmVkZW50aWFsVG9rZW4iOiIzWktaaWFhdGNRNkpheld5WiIsImlzQ29yZG92YSI6ZmFsc2V9
and response is: 404 File Not Found
I've already added to my Slack application following redirect urls:
http://localhost:3000/_oauth/slack?close
http://localhost:3000/
Unfortunately it does not work. I am not sure what happened. It was working week ago and stopped yesterday. Users can't sign in.
This is my loginWithSlack method:
Meteor.loginWithSlack({requestPermissions: ["identity.basic", "identity.email", "identity.avatar"]}, (error) => {
if (error) {
$notification({
type: 'error',
title: 'Signup with slack error',
message: error.error ? error.error.message : JSON.stringify(error)
});
console.log(error);
slackLog.error(error);
} else {
this.$router.push({name: 'home'})
Meteor.call('loginSlackUpdate', (error) => {
if (error) {
$notification({
type:'warning',
title: "Error activating account",
message: error.error ? error.error.message : JSON.stringify(error)
});
slackLog.error(error);
}
});
}
});
The '?' in the redirect_uri is no longer accepted by Slack as a valid character. You can remove it by configuring the loginStyle property when configuring your Slack service (in your server side application code) :
ServiceConfiguration.configurations.upsert(
{ service: 'slack' },
{
$set: {
loginStyle: "redirect",
clientId: "1292962797", // See table below for correct property name!
secret: "75a730b58f5691de5522789070c319bc"
}
}
);
Link is here : http://docs.meteor.com/api/accounts.html#service-configuration
For more details, you can check this issue out too : https://github.com/meteor/meteor/issues/2758
Hope this helps!
Related
I'm using NextAuth.js for Next.js authentication. Login works fine, but the page is still reloading on wrong credentials. It doesn't show any error. I need to handle error to show some kind of toast message.
signIn("credentials", {
...values,
redirect: false,
})
.then(async () => {
await router.push("/dashboard");
})
.catch((e) => {
toast("Credentials do not match!", { type: "error" });
});
When passing redirect: false to its options, signIn will return a Promise that always resolves to an object with the following format.
{
error: string | undefined // Error code based on the type of error
status: number // HTTP status code
ok: boolean // `true` if the signin was successful
url: string | null // `null` if there was an error, otherwise URL to redirected to
}
You have to handle any errors inside the then block, as it won't throw an error.
signIn("credentials", { ...values, redirect: false })
.then(({ ok, error }) => {
if (ok) {
router.push("/dashboard");
} else {
console.log(error)
toast("Credentials do not match!", { type: "error" });
}
})
Just getting started with Firebase phone auth. Seems pretty slick however I've hit a wall with a bug.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "SESSION_EXPIRED"
}
],
"code": 400,
"message": "SESSION_EXPIRED"
}
}
Starting with the Captcha: (standard documentation code!)
var applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', {
'size': 'invisible',
'callback': function(response) {
},
'expired-callback': function() {
}
});
Its rendered and the captcha works well.
Next is the sign-in bit where you are sent the auth code to your phone. Works great:
$scope.signInWithPhoneNumber = function signInWithPhoneNumber() {
var phoneNumber = "*censored*";
var appVerifier = window.recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, applicationVerifier)
.then(function (confirmationResult) {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
window.confirmationResult = confirmationResult;
$scope.setConfirmationResult(confirmationResult);
alert('Result: ' + JSON.stringify(confirmationResult));
}).catch(function (error) {
// Error; SMS not sent
alert('Error: ' + error);
// ...
});
};
Finally its the authentication of the code that the user inputs from the text message. Here is when I get the error 400:
$scope.AuthenticateCode = function (code) {
var code = String(document.getElementById("auth_code").value);
var confirmationResult = $scope.getConfirmationResult();
alert(code);
confirmationResult.confirm(code).then(function (result) {
// User signed in successfully.
var user = result.user;
console.log('Signed In! ' + JSON.stringify(user));
// ...
}).catch(function (error) {
// User couldn't sign in (bad verification code?)
// ...
});
}//end of AuthenticateCode
The error is coming from the VerifyPhone method:
https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPhoneNumber?key=censored
Any help or ideas?
Many Thanks,
Kieran
Ok, there are 2 likely reasons:
The code expired. The user took too long to provide the SMS code and finish sign in.
The code was already successfully used. I think this is the likely reason. You need to get a new verificationId in that case. Get a new reCAPTCHA token via the invisible reCAPTCHA you are using.
You are most likely to forget the "Country Code" before the phone no.
That is why firebase throw error 400 which means invalid parameters
If it's an Ionic3 project, change the following lines:
Imports:
import { AngularFireAuth } from 'angularfire2/auth';
import firebase from 'firebase';
Create var:
public recaptchaVerifier: firebase.auth.RecaptchaVerifier;
on "ionViewDidLoad()"
this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
on "your_method(phoneNumber: number)"
const appVerifier = this.recaptchaVerifier;
const phoneNumberString = "+" + phoneNumber;
this.fireAuth.auth.signInWithPhoneNumber(phoneNumberString, appVerifier)
.then(confirmationResult => {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
let prompt = this.alertCtrl.create({
title: 'Enter the Confirmation code',
inputs: [{ name: 'confirmationCode', placeholder: 'Confirmation Code' }],
buttons: [
{
text: 'Cancel',
handler: data => { console.log('Cancel clicked'); }
},
{
text: 'Send',
handler: data => {
confirmationResult.confirm(data.confirmationCode)
.then(result => {
// Phone number confirmed
}).catch(error => {
// Invalid
console.log(error);
});
}
}
]
});
prompt.present();
})
.catch(error => {
console.error("SMS not sent", error);
});
Reference:
Firebase Phone Number Authentication
I got into a similar situation when a POST request to google API was returning Bad Request 400. When the message was logged, it said:
All requests from this device are blocked due to Unusual Activity. Please try again later
The issue was when the ReCaptcha was sensing a bot out of my development environment and it worked well when I tried later. During the rest of the development, I turned off this feature for easy work.
I was following the twilio tutorial but was having issues making the http call. I replaced the SID and token with my own, however when I submit the call I receive the following error:
Error: failed [401] {"code": 20003, "detail": "Your AccountSid or AuthToken was incorrect.", "message": "Authentication Error - No credentials provided", "more_info": "https://www.twilio.com/docs/errors/20003", "status": 401}(…).
I am confused because I am providing the correct credentials. My code is below. Thanks!
HTTP.call(
"POST",
'https://api.twilio.com/2010-04-01/Accounts/' +
'sid' + '/SMS/Messages.json', {
params: {
From: '+14013541756',
To: "+14012610096",
Body: "yo"
},
// Set your credentials as environment variables
// so that they are not loaded on the client
auth:
'SID+ ':' +
'token'
},
// Print error or success to console
function (error) {
if (error) {
console.log(error);
}
else {
console.log('SMS sent successfully.');
}
}
);
}
I don't this will even compile:
auth:
'SID+ ':' +
'token'
Should it be
auth:
SID+ ':' +
'token'
But that might be a red herring, have you checked your environment variables are set properly, with a console.log(process.env.XXX) - which assumes this method is being called from the server...?
I try to create User Registration. I have install
accounts-base 1.2.2* A user account system
accounts-password 1.1.4* Password support for accounts
On client side :
var userNew = {
password: textPassword,
username: textUserName,
profile: {
address: textAddress
}
};
Accounts.createUser(userNew, function (err) {
if (err) {
alert(err.message);
} else {
Router.go('/');
}
});
But show error :
I20160423-17:47:07.299(7)? Exception while invoking method 'createUser' TypeError: Cannot read property 'accessToken' of undefined
Also i have set on server side :
Accounts.config({
forbidClientAccountCreation : false
});
I done with update & recreate PROJECT. I dont figure whats the problems. but recreate project solved this problems.
Hopelly its helps others
I'm looking for a working example of Meteor.loginWithGoogle (with meteor 0.6.4.1).
I found this one for loginWithGitHub (https://www.eventedmind.com/posts/meteor-customizing-login) that works fine with GitHub.
It works fine without parameters as show here on client side :
Template.user_loggedout.events({
"click #login": function(e, tmpl){
Meteor.loginWithGoogle({
}, function (err) {
if(err) {
//error handling
alert('error : '+err.message);
} else {
}
});
}
});
with the Accounts params on server side :
Accounts.loginServiceConfiguration.remove({
service: 'google'
});
Accounts.loginServiceConfiguration.insert({
service: 'google',
clientId: 'XXXXXX',
secret: 'YYYYYY'
});
In this case how can i get currentUser information especially the mail ?
Is there a way to get the Google+ profile of the user (if he has one and allows this), the user's avatar for example ?
What are the needed parameters for requestPermissions: , what can i get with this ?
Thanks
After some research i build my own example available here : https://github.com/lc3t35/googlelogin
Thanks to :
https://github.com/m2web/githublogin
https://github.com/ananta-IO/marq
Meteor/MongoDB see available fields for publish?
https://github.com/mrtnbroder/meteor-snippets/blob/master/snippets/js/Accounts/loginWithGoogle.sublime-snippet
https://developers.google.com/accounts/docs/OAuth2Login#obtaininguserprofileinformation