After using STRAVA – OAUTH2 of laravel, I am getting following error. Could anyone help me on this
ErrorException in StravaController.php line 27:
Undefined property: App\Http\Controllers\Api\v1\StravaController::$app
This error occured when provided this line of code inside the function and before the Socialite method
$key = 'SocialiteProviders.config.strava';
$config = new \SocialiteProviders\Manager\Config('key', 'secret', 'callbackUri');
$this->app->instance($key, $config)
You have to create an strava library object called app with client id and client secret. Then you can call the instance.
Related
I am following a grafikart tutorial on the back-end of an API under laravel, but creating a comment module, and since yesterday I have this message why. I think that I come from a call or from a space name but I know ... on postman also it returns to me errors.
postman:
error message:
Add the model namespace to your call, make sure you have a method called allFor
$comments = \App\Comment::allFor();
I have a Laravel app and I need to check if a user is logged and who from a external script. I'm using the following lines to load Laravel and try to check it.
require_once __DIR__.'/../../../vendor/autoload.php';
$app = require_once __DIR__.'/../../../bootstrap/app.php';
$app->make('Illuminate\Contracts\Http\Kernel')
->handle(Illuminate\Http\Request::capture());
/*if (Cookie::get(config('session.cookie')) != "") {
$id = Cookie::get(config('session.cookie'));
Session::driver()->setId($pericod);
Session::driver()->start();
}*/
$isAuthorized = Auth::check();
if(!$isAuthorized){
echo "NO AUTORIZADO";
exit();
}
With this lines I can access any Laravel function and I can check the login if I made GET request to the external scripts, but when the request is POST it always fails. I'm unable to check the login and I see that the session changes because can't get the existing session.
I have made many tests and I think that somethings of Laravel are not working fine, like routes or middlewares. I can made it work if I disable all encryption of the cookies and the session, but I want to use this security functions.
I'm using updated Laravel 5.7 and I had this code working in Laravel 5.4
Thank you for your help.
I discovered the problem,
The trick is that the route is external to laravel so laravel's route resolver identifies the current route as /.
It was working on GET requests because in my routes file I have the / route only as get. If I set the / route as any, everything works.
I wasn't seeing the problem because I was not terminating Laravel's execution. If I change the logged user verification to this, it shows the error:
$isAuthorized = Auth::check();
if(!$isAuthorized){
echo "NO AUTORIZADO";
$response->send();
$kernel->terminate($request, $response);
exit();
}
This two lines ends laravel execution and returns the error "405 Method Not Allowed".
$response->send();
$kernel->terminate($request, $response);
Thank you for your help.
I am using laravel ThrottlesLogins in my custom facade class as trait. I am using
if($this->hasTooManyLoginAttempts($request))
return $this->ThrottleActions($request);
in my login method, but why I am facing the subject error
Call to undefined method Modules\User\Services\web\facade\WebAuth::loginUsername()
However on local its working fine. But when I update code online server. I am facing this error.
This method loginUsername() already exist in ThrottlesLogins trait.
I follow up this tutorial using Laravel 5.4 Creating your first Laravel app and adding authentication
But I can't retrieve Auth0 users, the registration works fine in my dashboard new users are created in Auth0 server, but not in my local database and also I can't dd(Auth0::getUser());
I get this error:
Class 'Auth0\Login\LoginServiceProvider' not found
I've added this
Auth0\Login\LoginServiceProvider::class
in my provider array and
'Auth0' => Auth0\Login\Facade\Auth0::class
in my aliases.
I did all steps on configuration from Auth0 docs: Auth0 PHP (Laravel) SDK
I'm out off option now!
Ok, figure it out now.
The error was coming from 'AppServiceProvider.php'
Just import those two classes in AppServiceProvider.php as:
use Auth0\Login\Contract\Auth0UserRepository as Auth0UserRepositoryContract;
use Auth0\Login\Repository\Auth0UserRepository as Auth0UserRepository;
And then your Register method should look like this:
public function register()
{
$this->app->bind( Auth0UserRepositoryContract::class, Auth0UserRepository::class );
$this->app->bind( Auth0UserRepositoryContract::class, Auth0UserRepository::class );
}
if you want to persist data in your database then Create your own Repository and update the bind method YourCustomerRepositoryContract::class, YourCustomerRepository::class
Just like that.
For more info about creating your own Repository
Auth0 PHP (Laravel) SDK Quickstarts: Login
i am trying to connect my magento 2.0 store from my laravel application, when i make OAuth call from laravel to my magento 2.0 store laravel throws an error Class 'OAuth' not found.
OAuth is installed on my system and code works perfectly out side laravel but when i place code inside of a Laravel controller it throws the error
following is my code of OAuth call that i am making from laravel
$oAuth = new OAuth($integratoinData->auth_data->consumer_key, $integratoinData->auth_data->consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
$oAuth->setToken($integratoinData->auth_data->access_token, $integratoinData->auth_data->access_token_secret);
$oAuth->fetch($integrationCredentials['url']);
$responseInfo = $oAuth->getLastResponseInfo();
please help me thank you in advance
Try adding '\' when making instance of OAuth:
$oAuth = new \OAuth($integrato...