My facebook app make Infinite loop in sdk 3.1.1 - facebook-php-sdk

I have iframe facebook app but reload making infinite loop.
Yesterday work fine, but not to day.
I'm using javascript and php sdk 3.1.1 with this code:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
oauth: true, // turn oauth
appId : 'myappId',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Canvas.setAutoGrow();
</script>
FB.getLoginStatus(function(response) {
if (response.session) {
var query = FB.Data.query('select publish_stream from permissions where uid={0}', response.authResponse.userID);
........................
}
}
If I delete "<script src="http://connect.facebook.net/en_US/all.js"></script>" line, it does not infinite loop, but the app not work like i want.

Facebook migrated JavaScript SDK to support OAuth2, and requiere that all apps must migrate to OAuth 2.0 by October 1, 2011 (but last time was december 14 2011) therefore, I change:
FB.getLoginStatus(function(response) {
if (response.session) {
........................
}
by
FB.getLoginStatus(function(response) {
if (response.authResponse) {
........................
}
because the app was initialized with OAuth 2.0 enabled.
case closed.

Related

Hangfire Dashboard broken after deployment - not load css and js

when working the development the dashboard is seen correctly, but when it is uploaded to production not load the css and js files
project version net core 3.1 api
hangfire error
my startup
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
Authorization = new[] { new CustomAuthorizationFilter() }
});
I tried the following without results, the server is windows and the authorization filter is simple... I'm not sure what the problem is... but it doesn't load the css and js files
app.Use((context, next) =>
{
// note : comment this to debug locally
context.Request.PathBase = "jobs";
return next();
});

(linkedin) IN.User.Authorize callback never fired [duplicate]

Since today, our application that uses the linkedin javascript SDK to authenticate users stopped working.
​
We realized that the call to https://platform.linkedin.com/in.js now redirects to https://platform.linkedin.com/xdoor/scripts/in.js.
​
Consequently, calls to IN.User.Authorize(callbackFunction) successfully opens the authentication dialog window but the callback is never fired anymore.
​
Also, in another part of our application we are using the IN.UI.Authorize.place().onWindowRemove.subscribe(callbackFunction) to track dialog closes. This feature has also stopped wording and now opens a new window with the url invalid:// and the console throws this error:
​
jSecure Error: URL should be absolute with allowed schemas, relative, a hash fragment or query string. TODO?client_id=XXXX&type=user-agent in.js:7
​
jSecure Error: URL should be absolute with allowed schemas, relative, a hash fragment or query string. invalid://?xdOrigin=https%3A%2F%2FXXX-XXX&xdChannel=XXXX&xd_origin_host=https%3A%2F%2FXXXX.XXXX in.js:7
​
jSecure Error: URL should be absolute with allowed schemas, relative, a hash fragment or query string. TODO?client_id=XXXX&type=user-agent
​
​
Do you have an idea on why this stopped working ?
EDIT: Bug reappeared as of 2019 01 28.
Try replacing window.IN.User.authorize with window.IN.user.authorize
window.IN.user.authorize is returning a promise and success callback is executed post login success. Its weird but working if we replace User with user
window.IN.user.authorize().then(function(data){
console.log("Logged in successfully .");
window.IN.API.Raw("/people/~:(id,first-name,last-name,formatted-name,headline,location,industry,current-share,num-connections,num-connections-capped,summary,specialties,positions,picture-url,site-standard-profile-request,api-standard-profile-request,public-profile-url,email-address)").method("GET").body().result(function (oData) {
that.props.dispatch(userCreation(linkedInProfileFormat(oData)));
});
},function(error){
alert("Linkedin failed because of harshita !");
});
Try this code. I did some changes and working fine for me. need to replace window.IN.User.authorize() TO window.IN.user.authorize()
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: XXXXXXXXX
authorize: true
</script>
<script type="text/javascript">
function liAuth(){
window.IN.user.authorize().then(function(){
getProfileData();
});
}
function setLoginBadge(profile) {
if (!profile) {
profHTML = "<p>You are not logged in</p>";
}
document.getElementById("given_name").value = profile.firstName;
document.getElementById("family_name").value = profile.lastName;
document.getElementById("email").value = profile.emailAddress;
document.getElementById("verifyOauthRequestLinkedIn").submit();
}
function onError(error) {
console.log(error);
}
function getProfileData() {
IN.API.Profile("me")
.fields(["id", "firstName", "lastName", "pictureUrl", "publicProfileUrl","email-address","headline"])
.result(function(result) {
setLoginBadge(result.values[0]);
})
.error(onError);
}
</script>
<img onclick="liAuth()" src="/images/linkedIn.png">

Google Analytics API OAuth after clicking "Allow" cannot connect to local host

I'm trying to obtain an access token for Google Analytics API.
After creating a project in the developers console and granting acess to the Analytics API I reached the "create credentials" step and created new credentials for a web application.
On these credentials I set the Javascript origins to http://localhost:8080 and also http://localhost:5000. Then I set authorized redirect URIs to http://localhost:8080/oauth2callback as well as http://localhost:5000/oauth2callback.
Then, when I attempt to authorize I'm asked to enter my clientId and secret, which I do, then new browser tab opens and I'm asked to choose an account and then after that select "Allow".
Then, when I click "Allow" I'm taken to this page:
I also tried creating credentials for an application type of "other" but the exact same thing happened.
I've found numerous posts on stack overflow about this but none of the answers were able to solve my problem. Not sure which other info to provide. I even tried clearing history and using different browsers but with no success.
How can I give my application authorization to Google Analytics using OAuth?
This issue has nothing to do with localhost or your redirect uris or JavaScript origins. The issue is that your code is not set up to handle the call back from the authentication server. It would have helped if you had posted your code so it will be hard to know what the problem might be.
You should check the official example here Hello analytics js tutorial
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello Analytics Reporting API V4</title>
<meta name="google-signin-client_id" content="<REPLACE_WITH_CLIENT_ID>">
<meta name="google-signin-scope" content="https://www.googleapis.com/auth/analytics.readonly">
</head>
<body>
<h1>Hello Analytics Reporting API V4</h1>
<!-- The Sign-in button. This will run `queryReports()` on success. -->
<p class="g-signin2" data-onsuccess="queryReports"></p>
<!-- The API response will be printed here. -->
<textarea cols="80" rows="20" id="query-output"></textarea>
<script>
// Replace with your view ID.
var VIEW_ID = '<REPLACE_WITH_VIEW_ID>';
// Query the API and print the results to the page.
function queryReports() {
gapi.client.request({
path: '/v4/reports:batchGet',
root: 'https://analyticsreporting.googleapis.com/',
method: 'POST',
body: {
reportRequests: [
{
viewId: VIEW_ID,
dateRanges: [
{
startDate: '7daysAgo',
endDate: 'today'
}
],
metrics: [
{
expression: 'ga:sessions'
}
]
}
]
}
}).then(displayResults, console.error.bind(console));
}
function displayResults(response) {
var formattedJson = JSON.stringify(response.result, null, 2);
document.getElementById('query-output').value = formattedJson;
}
</script>
<!-- Load the JavaScript API client and Sign-in library. -->
<script src="https://apis.google.com/js/client:platform.js"></script>
</body>
</html>

Meteor pages blank for logged users on some systems

I have a Meteor app which works fine on my older MacBookPro (10.6.8 Snow Leopard) and also runs on a newer MacBook (10.10.5) but some of the pages don't show when I login. The same is true of my other friend who works on a similar MacBook. We get the browser warning:
Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
Here is a live and perfectly functional version of the app: http://sscprobs.meteor.com/
layout.js shows at all times with header, login buttons, etc.
When user is not logged in, the home route, for example, shows intro text as normal, but that text disappears upon login. It seems to me the trouble must lie with the accounts system and/or routing. Logging in with either Google or Twitter reproduces the problem equally (Facebook login is not configured for now).
I'm not sure how to troubleshoot. Here is my router.js:
Router.route('/', function() {
this.render('home');
});
Router.route('/user/:_username', {
name: 'user_profile',
data: function() { return Meteor.user();}
});
Router.route('/create', function() {
this.render('createEvent');
}, {
name: 'create'
});
Router.onBeforeAction(function () {
if (!Meteor.userId()) {
// if the user is not logged in, render the Login template
this.render('home');
} else {
// otherwise don't hold up the rest of hooks or our route/action function
// from running
this.next();
}
}, {
only: ['create']
});
Router.route('/insert', function() {
this.render('insertEvent');
});
Router.route('/events/:slug', {
name: 'event',
data: function() { return Events.findOne({slug: this.params.slug});}
});
Router.route('/useremail', function() {
this.render('userEmail');
}, {
name: 'userEmail'
});
Router._filters = {
hasCompletedProfile: function() {
if(!this.ready()) return;
var user = Meteor.user();
if (user && ! userProfileComplete(user)){
this.render('userEmail');
} else {
this.next();
}
},
};
// copied from Telesc.pe router.js
filters = Router._filters;
Router.onBeforeAction(filters.hasCompletedProfile);
Router.configure({
layoutTemplate: 'layout',
});
Here my package list:
accounts-facebook 1.0.4 Login service for Facebook accounts
accounts-google 1.0.4 Login service for Google accounts
accounts-twitter 1.0.4 Login service for Twitter accounts
aldeed:autoform 5.5.0 Easily create forms with automatic insert a...
aldeed:collection2 2.5.0 Automatic validation of insert and update o...
autopublish 1.0.3 Publish the entire database to all clients
blaze 2.1.2 Meteor Reactive Templating library
cmather:handlebars-server 2.0.0 Allows handlebars templates to be defined o...
email 1.0.6 Send email messages
insecure 1.0.3 Allow all database writes by default
iron:router 1.0.9 Routing specifically designed for Meteor
meteor-platform 1.2.2 Include a standard set of Meteor packages i...
mquandalle:jade 0.4.3_1 Jade template language
msavin:mongol 1.1.5 The insanely handy development package for ...
percolate:synced-cron 1.2.1 Allows you to define and run scheduled jobs...
service-configuration 1.0.4 Manage the configuration for third-party se...
stevezhu:fbgraph 1.2.0* Node.js module to access the Facebook graph...
todda00:friendly-slugs 0.3.4 Generate URL friendly slugs from a field wi...
twbs:bootstrap 3.3.5 The most popular front-end framework for de...
useraccounts:bootstrap 1.12.3 Accounts Templates styled for Twitter Boot...
useraccounts:iron-routing 1.12.3 UserAccounts package providing routes conf...
Any ideas?

ASP.NET website authentication with facebook

I've seen a lot of documentation about integration between ASP .NET web sites and Facebook, but I haven't found a simple working example, even using Facebook C# SDK.
All I want is a "login with Facebook" example, and to get basic user information (such as name, email and photo).
Can you guys help me please?
Thanks a lot!
as you say using Facebook C# SDK, then here is path and some code for canvas application:
1- Create your web application from visual studio
2- install nuget and get by nuget Facebook C# SDK
3- from https://developers.facebook.com/apps/ create and configure your app.
4- Your web config for facebook integration :
<configuration>
<configSections>
<section name="facebookSettings" type="Facebook.FacebookConfigurationSection" />
</configSections>
<facebookSettings appId="123..." appSecret="abc...." siteUrl="http://apps.facebook.com/myapp/" canvasPage="http://app.facebook.com/myapp" secureCanvasUrl="https://myapp.com/" canvasUrl="http://myapp.com/" cancelUrlPath="http://www.facebook.com/" />
...
By using sdk, you can parse signed request or cookie written by facebook js sdk
FacebookWebContext fbWebContext = new FacebookWebContext();
//Check if user auhtenticated
bool IsAuthenticated = fbWebContext.IsAuthenticated();
Here you can have friend count by:
FacebookWebClient fbWebClient = new FacebookWebClient();
dynamic result = fbWebClient.Get("me/friends");
var friends = result["data"];
int frienCount = friends.Count;
For the client side:
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: '123...',
status: true,
cookie: true,
xfbml: true,
oauth:true });
};
(function () {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
} ());
<!-- rest of your html -->
</body>
For login & asking permission from javascript
FB.getLoginStatus(function(response) {
console.log( response );
if ((response.status)&&(response.status=='connected')) {
//successs
} else {
//user declined
}, {scope:'user_likes, offline_access'}
});
I prefer in my project to client side login thus not yet registered user have landing page, if for example submit form then I call code block above.
Note: you have to set P3P header for Internet explorer to read/write cookie depending of your server. for IIS, global.asax:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");
}
Volià

Resources