signinwithemail link error using react-native, Firebase and expo - javascript

Error encountered
This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.
I am trying to use signin with email link in firebase and React Apllication build using EXPO
when i run this code i get the email link but when i click on that link i get this error
My code is
const actionCodeSettings = {
url: ` https://servy-a8ef2.firebaseapp.com`,
handleCodeInApp: true,
};
await firebase
.auth()
.sendSignInLinkToEmail(email, actionCodeSettings)
.then(function () {
})
.catch(function (error) {
console.log("error", error);
// Some error occurred, you can inspect the code: error.code
});

I don’t know if it’s still relevant, I had the same error. Maybe for someone it will be useful.
First of all, check your link, there is a space before https, firebase may encode it as "%20https..." That’s why it does not work. And check your quotes as well, the back quotes can be encoded differently.
I had problem with an environmental variable, i put the value with quotes, that google encoded as "%27http......%27". So that was my error.

Related

Capture Errors From Embed/Iframe

So I'm building a React application for a client and they want me to find when a user is not authenticated, and redirect to a different site. When the user is not authenticated, the app returns the errors you see below. Apologies for the blackout, but basically the errors come from the embed itself and not my app so putting try...catch around the authentication/embedding does not work.
The code that kicks off the auth and embed process looks like this. I've simplified it to what's important and removed information about the client.
async function setupEverything(x) {
LookerEmbedSDK.init('<URL>')
await LookerEmbedSDK.createDashboardWithId(x)
.appendTo('#dashboard')
.build()
.connect()
.then(setupDashboard) // Ignore this, has nothing to do with embed.
.catch((error) => {
console.error('An unexpected error occurred', error)
})
}
Essentially the embed is in an iframe, probably the error is thrown from the iframe. Is there a way to listen to this error event given that I cannot access the code within the iFrame? Should I tell my clients it's a lost cause?

Can't login with my NightmareJS v2 script in a specific site. I get Oracle error

I am a total newbie.
I've made a small script to login in sites, but it doesn't work in a particular one (the one I made this script for)
and I get this error if I use DEBUG: in terminal
Error 403--Forbidden From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.4 403 Forbidden The server understood the request, but is refusing to fulfill it. Authorization will not help and the request
SHOULD NOT be repeated. If the request method was not HEAD and the
server wishes to make public why the request has not been fulfilled,
it SHOULD describe the reason for the refusal in the entity. This
status code is commonly used when the server does not wish to reveal
exactly why the request has been refused, or when no other response is
applicable.
OR instead of the webpage I get a page with the ORACLE ACCESS MANAGER logo and this message
Error System error. Please re-try your action. If you continue to
get this error, please contact the Administrator.
Is there any extra security layer that doesn't let me to enter and how to bypass it?
Here is the code:
const Nightmare = require('nightmare');
const nightmare = Nightmare({ show: true});
nightmare
.goto('path')
.type('input[name="username"]', 'username')
.type('input[name="password"]', 'password')
.click('input[type="submit"][value = "OK"]')
.wait(5000)
.evaluate(() => document.querySelector('body').innerText)
.end()
.then(console.log)
.catch(error => {
console.error('Search failed:', error)
});
So the problem was lying that the 'path' in the .goto method for that particular
site shouldn't be the url of the login page but the url that the site redirects me after I normally login or any other address that I have access to after I have logged in the site.

Firebase FCM (Javascript): Error when request permission (Error status = 500)

I'm new to Firebase Cloud Messaging and I need to implement notifications in my webapp.
If the browser requests notification for the first time there is no error occurred and the token fetched successfuly. But if I delete the notification from the browser parametre (I use Chrome) and ask for permission again, it shows me an error in the console.
DELETE https://fcmregistrations.googleapis.com/v1/projects/teak-perigee-*****/registrations/dcVW8MdcapIy5CrSqGutkj:APA91bFoslZEsjgIk16CUfol*****************
FirebaseError: Messaging: A problem occured while unsubscribing the user from FCM: FirebaseError: Messaging: A problem occured while unsubscribing the user from FCM: Internal error encountered. (messaging/token-unsubscribe-failed). (messaging/token-unsubscribe-failed).
Actually the token is fetched even this error occurs. but in this situation I handle the new token in the catch block of the promise. This is my code when permission is fired:
askForPermissioToReceiveNotifications = () => {
const messaging = firebase.messaging();
Notification.requestPermission().then(async (permission) => {
if (permission == 'granted') {
try {
const token = await messaging.getToken();
if (token) {
console.log(token);
return token;
} else {
console.log('No Instance ID token available. Request permission to generate one.');
}
} catch (error) {
console.log('An error occurred while retrieving token. ', error);
//BUT THE NEW TOKEN SUCCESSFULY FETCHED
const token = await messaging.getToken();
if (token) {
console.log(token);
return token;
} else {
console.log('No Instance ID token available. Request permission to generate one.');
}
}
}
})
.catch(error => console.log(error));
}
I don't know if I miss something and I hope I can find a solution.
I faced a similar issue and believe this may be the explanation.
Issue was introduced in version 7.0.0 of the firebase-js-sdk. A workaround for now is to use version 6.6.2 or lower. I have filed a Github issue here for users effected to track.
So to enable use an older version just update the following in your index.html:
<script src="/__/firebase/6.6.2/firebase-app.js"></script>
<script src="/__/firebase/6.6.2/firebase-messaging.js"></script>
and change the following to your service worker file (typically named: firebase-messaging-sw.js):
importScripts('/__/firebase/6.6.2/firebase-app.js');
importScripts('/__/firebase/6.6.2/firebase-messaging.js');
it turns out that new versions of Firebase SDKs depend on a new internal infrastructure service, called FIS (the Firebase Installations Service) for targeting identifiers ("FIDs" or "Instance-IDs").
If you are using API key restrictions for the API keys you use in your application, you will have to extend those restrictions to allow usage with the new Firebase Installations Service at firebaseinstallations.googleapis.com.
To allow your API key in question to be used with the new Firebase Installations API:
go to the Google Cloud Console
choose the relevant project (i.e. the project you use for your application)
open the menu and go to APIs & Services -> Credentials
click Edit API key for the API key in question
scroll down to API restrictions
from the dropdown, choose FCM Registration API
click Save
wait a couple of minutes for Google servers to update and retry...
The Firebase library has a bug where it saves the token in an indexed database in your app. When you delete your credentials, it fails to delete the token and instead tries to fetch the old token when creating a new one, which leads to an error since the token no longer exists in Firebase. To resolve the issue, simply follow these steps.
-Open Google Chrome DevTools by pressing F12
-Click on the Application tab.
-Expand the Storage section in the left-side panel.
-Expand IndexedDB
-Expand firebase-messaging-database
-Right click on the key-value and delete it
-Refresh your app and the error is gone

Client-side Google OAuth 2.0 stalling out in Instagram's webview

I have a working client-side javascript OAuth 2.0 package handling authentication through Google. But when I try to use it to sign up or login to my site from within an Instagram or Facebook webview, I get an infinite loading circle and a very tiny message: "One moment please..." —
Screenshot of the tiny eternal loader
Looking into the problem, I see that Google is currently encouraging developers to switch to a web-browser auth flow, which seems to be what I have — https://www.zdnet.com/article/google-bans-logins-from-embedded-browser-frameworks-to-prevent-mitm-phishing/ — but I can't really tell what aspect is causing Insta to get stuck without throwing an error. The flow works perfectly within Twitter's webview, I should mention. It only seems to be the FB-owned platforms.
I'll include some of the front end code (React, using a "gapi-client" wrapper), because I don't think it's a backend issue. I am sending the token to my Django server to convert it eventually, but I think it's getting locked up on a redirect before that happens.
MOUNTING:
gapi.load("client:auth2", () => {
gapi.auth2.init({client_id: "<CLIENT ID KEY>"});
});
AUTHENTICATING:
const authenticate = () => {
let gProfileObject = gapi.auth2.getAuthInstance();
let scope = "profile email";
return gProfileObject
.signIn({scope: scope})
.then((res) => {
let username, googleResponse;
if (res.w3) {
googleResponse = res;
username = res.w3.U3;
localStorage.setItem("goog_avatar_url", googleResponse.w3.Paa);
localStorage.setItem("goog_name", googleResponse.w3.ig);
localStorage.setItem("goog_email", googleResponse.w3.U3);
}
//MOVES ON TO THE NEXT STEP IN THE SIGNUP PROCESS, COLLECTING ADDITIONAL INFORMATION FROM THE USER
this.props.oAuthToggle(googleResponse.Zi.access_token);
this.props.handleSpecialSubmit();
}).catch(err => {
console.log(err)
)
};
Has anyone had a similar issue with Google OAuth 2.0 on Insta or Facebook since the new changes were announced? Where did you seek a solution, and what did you need to change about your OAuth package to fix it? Thanks!
Instagram browser doesn't support popups natively, it tries to swap windows, but sometimes crashes. So you can change google API behavior, set {ux_mode: "redirect", redirect_uri: "http://yoursite/url-to-redirect-after-google-login"} in gapi.auth2.init procedure.
But for now in Safari "redirect flow" fails. Finally I solved this problem by using "low level" methods like described here:
https://developers.google.com/identity/protocols/oauth2/javascript-implicit-flow#example
(see "OAuth 2.0 Endpoints" tab)

FCM gettoken() stopped working, returning DOM versionerror

I am trying to get the token of my current device via firebase cloud messaging. I am using the following code:
messaging.getToken().then(function(refreshedToken) {
console.log("success ",refreshedToken);
}).catch(function(err) {
console.log('Unable to retrieve refreshed token ', err);
});
I then registered the device as part of a device group for one of my users(as per the firebase documentation). Now, however, whenever I try to get my device token, I get the following error: "The operation failed because the stored database is a higher version than the version requested." I tried clearing local history, but that didn't help. I also tried switching browsers. I don't know what the "stored database" even is. Is there any way to fix this? thanks!

Categories

Resources