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

Problem with refreshToken method #28

Closed
Deltenman opened this issue Sep 21, 2023 · 5 comments · Fixed by #31
Closed

Problem with refreshToken method #28

Deltenman opened this issue Sep 21, 2023 · 5 comments · Fixed by #31
Assignees
Labels
bug Something isn't working

Comments

@Deltenman
Copy link
Contributor

Deltenman commented Sep 21, 2023

When I try to refresh token with method

  Future<http.Response> refreshToken(String refreshToken, String? clientSecret,
      {String scope = "read"}) async {
    return await http.post(
        Uri(
          scheme: parseScheme(),
          host: parseHost(),
          port: parsePort(),
          path: "api/login/oauth/refresh_token",
        ),
        body: {
          'grant_type': 'authorization_code',
          'refresh_token': refreshToken,
          'scope': scope,
          'client_id': config.clientId,
          'client_secret': clientSecret
        });
  }

, I never get answer with the new token. Tried with/without clientSecret, tried with access/refresh/auth tokens (because thought that have incorrect variable for token) -- no luck. But if I try to do this request manually

final response = await http.post(
    Uri(
      scheme: "https",
      host: dotenv.get('CASDOOR_ENDPOINT').split("//").last,
      port: 443,
      path: "api/login/oauth/refresh_token",
    ),
    body: {
      'grant_type': 'refresh_token',
      'refresh_token': data.token.refreshToken,
      'scope': "read",
      'client_id': dotenv.get('CASDOOR_CLIENT_ID'),
      'client_secret': dotenv.get('CASDOOR_CLIENT_SECRET'),
    });

, I get the new token. What problem could be in library's method?

@casbin-bot
Copy link

@hsluoyz
Copy link
Member

hsluoyz commented Sep 27, 2023

@Deltenman what's the difference between the two requests? What's the key point you want to specify here?

@Deltenman
Copy link
Contributor Author

@hsluoyz another grand_type: I using 'grant_type': 'refresh_token', in your method it's 'grant_type': 'authorization_code',

@hsluoyz
Copy link
Member

hsluoyz commented Sep 27, 2023

@Deltenman can you make a PR to fix it?

@Deltenman
Copy link
Contributor Author

@hsluoyz #31

@hsluoyz hsluoyz added bug Something isn't working and removed question Further information is requested labels Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants