my project work very well in local server but when i publish it in live hosting everything work except the oauth2 not work and give me Route [login] not defined
i dont khnow were is the problem
my .htaccess
my Route api
Laravel redirect you to login route when API request doesn't authenticated, so add this line to routes/web.php file:
Route::post('login', [ 'as' => 'login', 'uses' => 'LoginController#do']);
Related
I had created a project before now and want to make API of it also I had a default laravel auth login module too now wants to generate sanctum auth for APIs but 2 auth running I guess.
pic shows working sanctum which I created for api
"account-settings", route in middleware not getting access but redirecting to "/login" page as shown in response, below I am providing api.php code too
In the pic this commit code // Route::group(['middleware' => ['auth', 'roles'],'roles' => ['admin','user','developer']], function () { is default laravel auth which have i commited in trying to make code working
I'm trying to use the #nuxtjs/auth module for OAuth2 authentication from Okta in a web app.
My app has a URL structure like: /browse/{folder} to view images from a particular folder, where {folder} can be any string of text. This is accomplished by creating a top-level view called browse.vue, a folder called browse, and a child component within that folder called _folder.vue. See more on nested routes in the Nuxt.js documentation in more detail here.
I've added the auth guard to the _folder.vue file. When I navigate to /browse, I'm redirected to /login and everything works perfectly from here with OAuth2 and Okta. When I'm returned to the app after logging in, I'm taken back to the /browse page.
However, when I navigate to a folder, like /browse/Test, I'm not redirected back to that folder after logging in. Instead, I'm returned to the / view of the app. From here, if I type the path in the address bar again, I am able to successfully view it as a logged in user. This indicates that the login was successful, but something about the redirect wasn't.
I noticed by looking at the cookies in the Firefox developer tools that an auth.redirect cookie is not created when I navigate to /browse/Test, so I think the auth module is not aware of where to redirect the user after logging in. When I navigate to /browse, the auth.redirect cookie is created, and the redirect occurs successfully.
Is there something I can do to make the auth module work for redirecting to these dynamic routes, or is this a bug with the module? Everything else about the module has worked perfectly in my app.
My auth configuration in nuxt.config.js, using #nuxtjs/auth version 4.9.1:
auth: {
fullPathRedirect:true,
redirect:{
callback:"/login",
logout:"/"
},
strategies: {
social:{
_scheme: 'oauth2',
authorization_endpoint: "https://{my-subdomain}.okta.com/oauth2/v1/authorize",
scope: ['openid', 'profile', 'email'],
access_token_endpoint: "https://{my-subdomain}.okta.com/oauth2/v1/token",
response_type: 'id_token',
token_type: 'Bearer',
client_id: process.env.CLIENT_ID,
client_secret:process.env.CLIENT_SECRET,
token_key: 'id_token'
}
}
}
Error: redirect_uri_mismatch
The redirect URI in the request, https://examrunner.com/googlecallback, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/677463899101-20bir5hd06sfoemjibm5qljn6skdr9mm.apps.googleusercontent.com?project=677463899101
'google' => [
'client_id' => '677463899101-20bir5hd06sfoemjibm5qljn6skdr9mm.apps.googleusercontent.com',
'client_secret' => '***************',//this is correct is just hidden
'redirect' => 'https://examrunner.com/googlecallback',
],
Open the Google Cloud API console for your project and select Credentials.
First, make sure to add the domain to 'Authorized domains'.
Be sure to click 'Save' at the bottom of the screen.
Next, you can add the URI to the 'Authorized redirect URIs' using the link from the error:
I will developing RestFul API with Lumen, but I got some problem.
When I try to get user with email. I got message
"The requested resource /user/test#example.com was not found on this server."
Here my route
$router->get('/{email}', ['as' => 'get', 'uses' => 'UserController#show']);
I try same url in laravel, but It works. I don't know why?
Anyone can suggest or help me, please.
In lumen Routes are like below
$app->get('/user/{email}', 'ThorController#show');
For more information : https://lumen.laravel.com/docs/5.4/routing#route-parameters
Also check your database credentials whether you are using different database for api then laravel application
I have used laravel auth scaffold in laravel 5.2
With this, I am able to access '/register' perfectly. Now, I am trying to put '/register' behind user login. Meaning, a user should be able to access '/register' only if it has logged-in else it should redirect to '/login' page.
NOTE: I have already created few users, so there is nothing to worry that how a user can login without registering as I am already having few users and that are the only one I need.
Can anyone help me in this please!
I am able to get this done. Here's the way I followed:
In routes.php, add these lines:
Route::auth(); //already there after laravel auth scaffold
Route::group(array('middleware' => 'auth'), function () {
Route::get('register', 'Auth\AuthController#showRegistrationForm');
Route::post('register', 'Auth\AuthController#register');
});
app/Http/Controllers/Auth/AuthController.php
Change from:
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
to:
$this->middleware($this->guestMiddleware(), ['except' => ['logout', 'showRegistrationForm', 'register']]);
And now, whenever I try to access /register without logging-in as some existing user, it redirects me to /login page. And if I logs-in and try to access /register page, it shows me register page as I want it to have.Reference: Laravel 5 Auth Register After Login