Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

429 Too Many Requests #66

Open
crazcdll opened this issue Oct 27, 2017 · 6 comments
Open

429 Too Many Requests #66

crazcdll opened this issue Oct 27, 2017 · 6 comments

Comments

@crazcdll
Copy link

crazcdll commented Oct 27, 2017

Client error: 'POST http://api.XXX.com.cn/oauth/token' resulted in a '429 Too Many Requests' response: Too Many Attempts.

Hello, when I send some requests a little fast, I would got the error above.

I have try do modify the throttle config in routes/web.php and routes/api.php, but nothing changed.

THX!

@qiutuleng
Copy link

qiutuleng commented Nov 8, 2017

Hi. @Zcdll
you can change the 29 line in the app/Providers/AuthServiceProvider.php file.

like this.

Passport::routes(function ($router) {
    /** @var \Laravel\Passport\RouteRegistrar $router */
    $router->forAuthorization();
    $router->forTransientTokens();
    $router->forClients();
    $router->forPersonalAccessTokens();

    // Passport Routes
    \Route::post('/token', [
        'uses' => 'AccessTokenController@issueToken',
//                'middleware' => 'throttle',
    ]);

    \Route::group(['middleware' => ['web', 'auth']], function ($router) {
        $router->get('/tokens', [
            'uses' => 'AuthorizedAccessTokenController@forUser',
        ]);

        $router->delete('/tokens/{token_id}', [
            'uses' => 'AuthorizedAccessTokenController@destroy',
        ]);
    });
});

@crazcdll
Copy link
Author

crazcdll commented Nov 9, 2017

Thx. @qiutuleng
My app/Providers/AuthServiceProvider.php just looks like below

public function boot()
{
    $this->registerPolicies();

    Passport::routes();

    // Token Lifetimes
//        Passport::tokensExpireIn(Carbon::now()->addDays(15));

    // Refresh Token Lifetimes
//        Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));

    // Pruning Revoked Tokens
//        Passport::pruneRevokedTokens();

    // Token Scopes
//        Passport::tokensCan([
//            'place-orders' => 'Place orders',
//            'check-status' => 'Check order status',
//        ]);

}

What you mean is to overwrite the Passport::routes()

@qiutuleng
Copy link

@Zcdll yes

@qiutuleng
Copy link

qiutuleng commented Nov 9, 2017

@Zcdll You can refer to here RouteRegistrar.php
It's the laravel official source code.

I just copy the forAccessTokens function code and disable throttle middleware.

example:
example

before:
before

after:
after

@crazcdll
Copy link
Author

@qiutuleng OK! Thanks a lot!

@Muhammadinaam
Copy link

Hi, this is a nice package but I think that the developers have stopped working on it. Maybe you can try this package: https://github.com/Muhammadinaam/speed-admin. It supports Laravel 8+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants