I am developing a facebook app using the Yii framework and want to use php sdk for authentication and other graph api calls. Though i have a tested script for authentication which works perfectly, i am not being able to implement it properly with my Yii framework generated files.
Right now i am making a FacebookHelper class in components with the whole authentication code in a
public function authenticator()
(have included facebook.php just before this function starts as well as imported using
'application.lib.*'
where the lib directory under protected is where my php sdk situated)
and the main controller which is the SiteController contains the following code for calling it.
public function actionIndex()
{
$fbhelper = new FacebookHelper();
$value=$fbhelper->authenticator();
if($value==0){
die("It works");
}
$this->render('index');
}
The application calls the login url using the
$facebook->getLoginUrl()
but facebook displays a msg that some error occured.
What am i doing wrong.
As i am new to the MVC model and Yii framework i am a little lost about how should i go about it, so it will be very much appreciated if you can also explain your answer(i.e. if there is some concept regarding the MVC architecture in it). Thankyou!
I'm using the following extension for facebook login using PHP-SDK and its working fine..
https://github.com/facebook/facebook-php-sdk-v4
Its specific with yii framework..
Related
I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository.
https://github.com/aspnet/AspNetCore/
I am highly interested in this method.
https://localhost:portnumber/Identity/Account/Login
Q1: How to find this method in my project and is it possible to debug it?
Q2: Why I dont see AccountController file in my new created app?
ANSWER:
It turned out, that from .net core 2.2 version if you want to see or change Identity controllers, you have to scaffold them manually.
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs=visual-studio#scaffold-identity-into-an-empty-project
The methods you are referring to are part of your application. Have a look under the Areas folder. There should be a subfolder called Identity. Under the Identity folder, you should find the AccountController and your Login action method should be inside this controller.
If you really want to look into the source code you need to have a look at the SignInManager.cs class and see how the SignInAsync method is implemented, which is used by the Login action method.
EDIT
Please refer to the screenshot below
EDIT 2
Structure for the newly created app using Web Application template
I basically have the same question as what is detailed here: Login redirect with asp.Core 2.0 and React. But that post never got an answer.
I've searched quite a bit and pretty much my problem is also touched on here here: https://github.com/aspnet/JavaScriptServices/issues/1440
I want to create a react front end application, but use .net core for the backend. I've used the .net core template with react redux as my boilerplate. I've also configured the .net identity on my backend. So I can actually use [Authorize] on my api calls and it works. By this I mean that if someone is authenticated the api returns data and if no one is authenticated it returns whatever the default redirect page is. I can confirm this by looking at the response on my chrome debugger and I see that it is showing the html for the register page which I've defaulted my login path to in configureapplicationcookie options.
The boiler plate is setup to serve up pages from the react client folder and uses react router. Therefore, I cannot set up any links to pages on my server. However, I'm able to manually navigate to my server pages for example /Account/Login and successfully login. My api calls through the links on the react front end then seem to work just as I would like.
What I would like to do is:
make calls from my react application to my server api
upon unsuccessful access to any api endpoint, redirect the user/request to my register page on the .net core server
have the user register and/or login and then redirect them to the route they came from through the react application.
Is this possible? Is it advisable?
I understand that you can manage all this on the front end using IdentityServer as detailed here: http://docs.identityserver.io/en/release/quickstarts/7_javascript_client.html. However, if all the infrastructure can be quickly spun up in .net and I can leverage the authentication templates, then I want to experiment with that setup and save time. Plus if this is feasible, why bother doing the setup on the front end using a 3rd party login provider? What am I missing?
Just created a new MVC4 Web API project - however I don't want any client-side for this, just the back-end to be referenced from other clients.
Is there any, sensible, reason that the default project template includes all of the javascript, views, etc?
Can they be removed without issue?
Default the web api project also contains the regular mvc stuff. If you do not intent to use the web api help pages (https://www.nuget.org/packages/Microsoft.AspNet.WebApi.HelpPage) or intend to develop a website part next to your api you can easily remove all views, scripts & statics.
I am creating an Web App and a Mobile App using Sencha
while doing so I am following sencha's recommended MVC pattern to develop these apps
Sencha recommends to create Worksapce and then create extjs and touch applications one by one inside the workspace to achieve code sharing between the apps.
from their documentation i understand that a piece of code thats shared between the two apps must go under the workspace directory
but i fail to understand how do you access this code from the respective Apps
presently i am creating the global functions inside a app and is available in that app only
Ext.define('MyApp.common.Util', {
statics: {
foo:function(){
...
}
});
and to access the function i use
requires:['MyApp.common.Util']
...
MyApp.common.Util.foo();
As u can see i can access function thats defined only under an app (MyApp..). can anyone provide me an example how to define a functions outside the app (within a workspace) and access them from various apps ?
Thanks
Check out the example app here: https://github.com/WebAppSolutionInc/sencha-cafe-townsend
They put the ExtJS and Sencha Touch app together with DeftJS https://github.com/deftjs/DeftJS
I am using MVC4's WEB API to expose a controller.
Initially I created created a MVC4 WEBAPI project, set the project not to open any web page, wait for an external app to call the URL (WEB API). The project in VS2010 is set to run from IIS7 Express, not VS2010's Dev Server. This works OK, the browser prompts me to down load a file. Which is OK for me, as the browser does not know what to do with the returned data (RAW TEXT).
Next, I created an AREA in the MVC4 project area, then added a controller (WEB API type).
Then I once again ran the project and in a browser entered the the URL (WEB API). And it fails.
Ed.
The DefaultHttpControllerFactory doesn't work with Areas by default. To get this functionality you have to write your custom HttpControllerFactory.
You can find how to do this at the post How to create HttpControllerFactory to support Areas
While it is possible to place WebApi Controllers in different Areas, ASP.NET MVC 4 RC will still treat these ApiControllers as if they all reside in the same namespace. This is a limitation of the DefaultHttpControllerSelector, which is responsible for selecting the appropriate ApiController.
Fortunately, you can inject your own implementation of this class. In fact, I've already encountered this very issue and written an "area aware" HttpControllerSelector. You can find a blog post of mine about this issue and its solution here:
http://blogs.infosupport.com/asp-net-mvc-4-rc-getting-webapi-and-areas-to-play-nicely/