IN.User is undefined in LinkedIn Javascript SDK - javascript

I am trying to log the user in programatically using LinkedIn Javascript SDK. I am not using the default flow (which includes the button as a script) as we need a custom size button, so here is my code:
//inside head...
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 'XXXXXXXXXXXX'
credentials_cookie: true
</script>
//inside some script tag
function loginWithLinkedIn() {
IN.User.authorize(linkedInLoginCallback); //yeah I have that method
}
However, as soon as call loginWithLinkedIn, I'm getting an error telling IN.User is undefined. IN itself is defined, but has only ENV and Event fields defined. How can I initiate LinkedIn login using JS (not a button/script tag)? I couldn't find any useful documentation anywhere, and LinkedIn's own documentation is terrible.

I was having the same issue. For me it was because we had changed the subdomain location of our application from www. to app. This change required me to go into the LinkedIn developer console and under the Javascript tab add our new app location to the list of Valid SDK Domains.

Related

Calling API from webpage for Alexa Skill Account Linking using Google OAuth

I have written an interface to use with an Alexa Smart Thermostat skill. I am using Google Oauth for credential checking and I followed the guide here: https://nicogaspa.medium.com/alexa-skill-account-linking-with-google-apis-2cbad07d2cf8 which has also been discussed here: Alexa skill account linking with Google APIs credentials, problem refreshing token
This has worked well for me until recently when I found that the skill had stopped working and I was unable to re-enable it. There are two problems that I am aware of:
The Google API appears to have changed and the Authorization URI now requires a number of mandatory parameters – client_id, redirect_uri, response_type & scope. I have added all of these to the URI specified on the Account Linking page in the Alexa developer console and the account linking now works OK (including the automatic refreshing of the token).
Having added the mandatory parameters, I have tried to get this to work on the HTML page that I used from Nicolo’s blog. I have been unable to get this to work, because Google complains with: “OAuth 2 parameters can only have a single value: client_id” (the reference to client_id is a red-herring as it changes depending on what’s included in the string). From searching around, it would appear that this is caused by having the parameters in the body and the header of the request. However, I can’t find a way to prevent this from happening. My HTML page looks like this:
<html lang="en-us">
<head>
<title>Your Skill</title>
</head>
<body>
<div>
<p>Welcome to the skill</p>
<p>Click on the button to continue</p>
</div>
<script language="javascript" type="text/javascript">
var urlParameter = window.location.search.substr(1);
</script>
<a href="https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=MYID.apps.googleusercontent.com&redirect_uri=https://layla.amazon.com/api/skill/link/MYURI&scope=https://www.googleapis.com/auth/userinfo.email"
onclick="location.href=this.href+urlParameter;return false;">
Login
</a>
</body>
</html>
Any ideas on how to call the api from the body of a webpage without including the parameters in the header and the body?
Thanks.

Occasional Amplitude "Invalid apiKey"

I'm trying to record events using the JS Amplitude API.
The setup instructions are to put code in the <head> of pages.
See Full instructions here.
Since I'm using React, I put the code in index.html
The event I'm trying to record is executed on componentDidMount on various pages:
componentDidMount() {
amplitude.getInstance().logEvent("test_profile_accessed", {page: `${test_info}`});
}
However, sometimes the event doesn't record because I get this error:
[Amplitude] Invalid apiKey. Please set a valid apiKey with init() before calling logEvent()
This error only happens every once in a while, with the other times successfully recording.
What is going on? I don't see any documentation about this error anywhere else.
As the docs state you have to set API key that you got after creating a project:
Insert your API Key. Replace API_KEY with the API Key given to you. You can find your project's API Key in your project's Settings page.
<script type="text/javascript">
// removed the code that loads the Amplitude JavaScript SDK
amplitude.getInstance().init("API_KEY");
</script>
Above script should be included inside your index.html head. Make sure you replace API_KEY with your actual API key.

Recaptcha v3 initialization interrupted

Recaptcha v3 initialization is not completing when using the production site.
The logo is no longer appearing and if I try to submit the form I'm getting this error : "Uncaught Error: Invalid site key or not loaded in api.js"
It's working when I'm using it on localhost from my PC
The only difference between the dev and the prod are the keys.
Any idea to why it's not loading properly ?
Changed the keys.
Tried on other web browsers.
There's 2 main ways I believe this is caused:
Your domain name should just be the domain. apple.com, not https://apple.com
Make sure you are including the sitekey in the render param when you add the script tag:
<script src="https://www.google.com/recaptcha/api.js?render=<v3_site_key>"></script>
I've gotten the error when I forgot to provide the site key here (originally thought I only had to pass it in as the first argument to grecaptcha.execute)

How to implement Google Analytics event tracking inside a React VR project?

This is loosely written to give a basic idea of what I'm trying achieve.
< VrButton onClick={props.userClick}>< /VrButton>
userClick={() => this.triggerTracking}
triggerTracking() {
ga('send', 'event', 'myEventCategory', 'myEventAction', 'myEventLabel');
}
I expect the code to trigger Google Analytics event tracking in the GA system when the user clicks on a button, but I get an error message - "ga is not a function".
I have GA set up in my index.html file, with the proper ID, and pulling in the latest analytics.js API.
React VR is all within a web worker context so it is not possible to access anything on your window without the use of native modules.
You can embed them directly in your client js and use the GA tracking functions as you normally would there. You will then call a function on your native module within your react VR app.
You can check out the documentation here: https://facebook.github.io/react-vr/docs/native-modules.html
Try using the window scope as:
window.ga('send', 'event', 'myEventCategory', 'myEventAction', 'myEventLabel');
I'm not familiar with React at all, but perhaps React causes some abstraction between the window and the react scope, making your ga() function unavailable.
Do next stps:
open the network debug tool of your browser.
reload your page
review loaded url list and check that www.google-analytics.com/analytics.js is loaded
If you does not see such url loaded - read google analitycks manual about how to setup google analytics on your page.
If you see such url replace url www.google-analytics.com/analytics.js with www.google-analytics.com/analytics_debug.js in your page, than reload and than go to console tab of your browser debugger and check the errors.

Google Drive JavaScript SDK - Share Dialog Not Working

I have an application (POARDS) set up using the Google Drive SDK.
I am mainly processing this application's data in PHP, but a few features (such as the share dialog) use the JavaScript API.
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script>
<script type="text/javascript">
init = function() {
s = new gapi.drive.share.ShareClient('737617002551');
s.setItemIds(["ncle837jp4berdbjftouwixsjub1fvt2"]);
}
window.onload = function() {
gapi.load('drive-share', init);
}
</script>
The issue is that when I try to launch the share dialog using s.showSettingsDialog(); the sharing system malfunctions. A blank modal with a loading message pops up, and after a few seconds, I recieve the following error message:
Sorry, sharing is unavailable at this time. Please try again later.
Upon further investigation, an error message in the development console is also available:
Refused to display 'https://drive.google.com/share…' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'
The message appears twice: once when the gapi.load(); call is made, and again when the s.showSettingsDialog(); call is made. In the Google documentation, it says that the share modal only has three requirements:
The user is signed in to Google
The user has installed your app
The URL of the page that launches the dialog must have the same origin as the Open URL registered for the app.
However, as far as I can tell, my application matches these three rules. Thus, the dialog should appear like normal.
Share dialog has strict requirements related to Content Security Policy. Your application must follow those strict requirements. Any deviation will cause issues like this with the Share dialog.
This link may assist you in further understanding those requirements: https://developer.chrome.com/extensions/contentSecurityPolicy

Categories

Resources