Linkedin Authentication using a WebView on Android occasionally fails - javascript

For some of our users, Linkedin authentication using a WebView doesn't work.
Linkedin WebView is displayed within an activity
The user types in the credentials
The Linkedin login screen just get refreshed
Some hints:
Not sure if it's related, but in my attempt to understand what is going on, I logged a Error and a Warning message using setWebChromeClient and got these:
Error: Cannot read property 'channel' of undefined -- From line 233 of https://www.linkedin.com/scds/common/u/lib/espany/1.0.0/espany.js
Warning: webkitURL' is deprecated. Please use 'URL' instead. -- From line 31 of https://static.licdn.com/scds/concat/common/js?h=25kaepc6rgo1820ap1rglmzr4-edgsl2z4e4gk56cy2m5kbpp1q-dtx8oyvln9y03x1ku6t0abhc9-cl5mre9823ndhfdrl4nozaofi-6isi7fr80gagap7736arbauct-8ohb0iio22nbqe1w8et54sawe-13kfns70b5ghzzqxzr194d2jo-cr2cf88zdeizqhuobqtot8sge-amjylk8w8039f2lwlov2e4nmc-47qp7uw3i5i1pqeovirlcc070-5pmigtkow46izwzcb8m1b57ly-br7xw7z07pbsy9z5545ze80zu-aikuay313zihm7be1fml6lb8y-7vr4nuab43rzvy2pgq7yvvxjk-9qa4rfxekcw3lt2c06h7p0kmf

Related

Stripe works in localhost but gives error in live

I'm currently developing a stripe checkout for my website, it's working in localhost but gives me this error : JSON.parse: unexpected character at line 1 column 1 of the JSON data. In localhost I get this error if I name in a JSON payment intent field that does not exist, I've already set the live website in HTTPS channel
Stripe has a support article that explains how to debug and fix this error.

MetaMask does not inject window.ethereum: Uncaught (in promise) TypeError: Cannot read property 'request' of undefined

To start, let me mention this is an in-browser project, so i can only use
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
So a few months back I made a dapp, which worked fine even tho I never set a provider, so I guessed it used the ones given by MetaMask.
However, i am using the guide here the only issue is the following code,
var account_global, connected = false;
async function connect() {
if (!connected) {
var wei;
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' }); // Waits for connection to MetaMask.
account_global = accounts[0];
web3.eth.defaultAccount = account_global;
console.log(account_global.toString() + " connected!");
connected = true;
console.log(account_global);
}
}
connect();
This code used to output the address of the metamask user after they approved metamask on my dapp, however I am receiving the error
Uncaught (in promise) TypeError: Cannot read property 'request' of undefined
The error just says that, my actual goal if i have to add providers and all is to use the ones from metamask, and allow connecting to metamask, the rest of the functions such as transfer or others i know how to handle them, it just seems that my issues come when i try loading the page.
I dont have an ether node to use, not planning on using nodejs either, only a single html file displaying the Metamask address, hence using the in-browser web3js.
I hope its just me not realizing something simple, because I cant seem to find the reason I cannot use web3js right now.
The actual problem is, that you need to run your script on some server. For testing purposes you can use localhost.
Please, refer to this link on how to start local server. And just open your file via localhost:XXXX where XXXX - are the port number.
Solved the mystery, seems to be just like the error code showed
Uncaught (in promise) TypeError: Cannot read property 'request' of undefined
genuinely meant that window.ethereum was undefined, so for no exact reason MetaMask would not inject ethereum, noticed that after reading Metamask and Web3js documentation, that my issue had nothing to do with their code, in fact i am gonna end up using the code shown on this answer.
https://ethereum.stackexchange.com/a/78987
The issues seeems that no matter the browser Metamask would not inject, so i tested it on multiple websites that usually require Metamask to connect and other normal sites just as google.com, to my surprise every site would have Metamask injecting ethereum apart from my own test site, so it meant that my site was cursed or something, or just the fact that Metamask does not inject on unhosted websites (just had the files on my destop to test), instead on an actual host it did inject and my tests were working on those sites.
Conclusion
Metamask requires a normal host to inject, it wont inject on a random file opened on your own workstation.
I had the exact same issue and it turned out my HTML was a bit dodgy (had an extra tag before the <html> tag) and that was preventing MetaMask from injecting web3.

Google Auth API Javascript idpiframe initialization error on Chrome

I use GSuite and I'm coding a very simple web app to use Google Auth API, and I get an exception "idpiframe_initialization_failed".
Now I have the exact HTML as shown in the google Sample:
https://developers.google.com/api-client-library/javascript/samples/samples
1) I've created a project on the Google Developer Console
2) I setup the OAUTH authorization screen
3) I've created the client ID, creating restrictions and redirection URL
4) I've also created the API KEY
5) Finally I've enabled the People API, because discovery services was failing when setting the discoveryDocs parameter
With all of these steps, When I call the gapi.client.init, it raises an exception ONLY in chrome, I cannot understand why.
The code for initializing the API is:
gapi.client.init({
apiKey: 'MY_API_KEY',
discoveryDocs: ["https://people.googleapis.com/$discovery/rest?version=v1"],
clientId: 'MY_CLIENT_ID.apps.googleusercontent.com',
scope: 'profile'
}).then(function (response) {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
},function(reason){
console.log('onerror');
console.log(reason);
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
The code is running the error block, and the message is:
details: "Failed to read the 'localStorage' property from 'Window': Access is denied for this document."
error:"idpiframe_initialization_failed"
Any ideas why I'm coming into this error?
Thanks!
I encountered the same issue. After investing some time, found the reason. This error is because in chrome settings, you have the Block third-party cookies and site data option enabled.
It can be resolved by disabling this option:
"To find the setting, open Chrome settings, type "Content settings" in the search box, click the Content Settings button, and view the fourth item under Cookies."
Uncheck the box "Block third-party cookies and site data".
Hopefully this helps you in resolving your issue.
The problem is with Google's API console and how it handles creating credentials.
It only seems to work when I access it through the following url
https://developers.google.com/identity/sign-in/web/sign-in#before_you_begin
There is a link that lets you create your app and the OAuth credentials.
When I go to the console and create it through that screen it doesn't seem to work.
After trying and re-create again and test with a fresh app I found out that the URL you add to the Authorized Javascript Origins doesn't always get added.
If everything is good then the url should be available in the credentials page
In my case, I just had to wait a bit for Google to take the origin into account. I cannot tell exactly how long it took. I waited ~30min. I then went to sleep and it was working the following morning.
Edit: Ooops I just realized I was using http:// and not https://. That was the actual problem.
I had the same problem and I searched for 3 days: Resolve " popup_closed_by_user" Go to your console.google go to your API MANAGE : Credentials:modify your credentials:
Authorized Javascript origin (http://localhost:port);
authorized redirect URI(http://localhost:port/auth/google/callback);
Example:|| Authorized Javascript origin (http://localhost:4200);
authorized redirect URI (http://localhost:4200/auth/google/callback)

Deezer JS API returning Location:http://www.mydomain.com.br/dz/channel.html#token|exception|unknown

im doing the software to play deezer`s songs, and im using the Deezer Javascript API.
But when i use getStatus of user there is a error:
Deezer JS API returning:
Location:http://www.mydomain.com.br/dz/channel.html#token|exception|unknown
and the throw exception:
Uncaught An error has occured, please retry your action
Or when i use login, the popup show the following error:
"You must enter a valid redirect uri"
What i need do to fix this errors?
You just have to set the domain of your website, not the whole URL and it will work.

chrome.identity.getAuthToken returning "bad client id: {0}" error

I'm trying to use chrome.identity.getAuthToken to get a token, but every time I try this error shows up:
OAuth2 request failed: Service responded with error: 'bad client id: {0}'
I have no idea why this is happening. The client ID I put in manifest.json is exactly the same as the one on the Google Developers Console, and the correct scopes is also included:
oauth2: {
"client_id": "NUMBERS-NUMBERS&LETTERS.apps.googleusercontent.com",
"scopes": ["https://www.googleapis.com/auth/SOME_SERVICE"]
}
The extension is up on the webstore, and I don't see why it is still giving the bad client ID error.
What is possibly causing this error? What am I missing here?
Just as a note for myself and for someone run into.
I have encounter this problems with chrome app , the answers is not my problem ,and finally I found the solution for my problem but produce the same error as the question.
As https://developer.chrome.com/apps/app_identity#client_id say is much special for chrome apps, you have to create a separate client id for your chrome app.
Go to the "API Access" navigation menu item and click on the Create an OAuth 2.0 client ID... blue button.
Enter the requested branding information, select the Installed application type.
you must to choose Installed application an set you Application ID.
what's your Application ID ?
chrome-extension://your application id
chrome-extension://gfmehiepojbflifceoplblionpfclfhf/
I overcomed this problem by setting up the email address and product name in "Consent screen" in the Google Developer Console.
Please refer to https://developers.google.com/console/help/new/#userconsent for detail.
I had a similar problem. Everything seemed to work fine on my own laptop, but when i ran it on another device i got that "bad client id" error.
My problem was that the client-id changed from one device to another, as i did not yet upload my extension to the chrome store.
To overcome that problem, i followed the instructions of How to change chrome packaged app id Or Why do we need key field in the manifest.json?.
You need to create a key to keep the client-id persistent through all devices.
Hope that helps finding the right answer for people with the same issue quicker.

Categories