0

I want to get access token from client credential grant. I tried this from the postman and ThunderClient where response threw with access token but when I tried using oauth or dio package it failed. It is only failing is flutter web.

I am using oauth2 package to get the client credential grant access token but it is throwing Error: "invalid_request" error_description : AADB2C99067 Public Client "ID" is not supported for non-interactive flow

final authorizationEndpoint = Uri.parse(env.Environment.claimApiUrl);
  static const clientIdentifier = env.Environment.claimApiClientId;
  static const clientSecret = env.Environment.claimApiClientSecret;
  static const scopes = env.Environment.claimApiScope;

  @override
  Future<Client> getTokenCode() async {
    Future<Client> auth = oauth2.clientCredentialsGrant(
      authorizationEndpoint,
      clientIdentifier,
      clientSecret,
      scopes: scopes,
      delimiter: ",",
      basicAuth: false,
    );
    

    return auth as Client;
  }

I also Tried using dio to post the data but it is throwing same error,

  @override
  Future<Client> getTokenCode() async {   
    final auth = await dio.post(
      authorizationEndpoint.toString(),
      data: {
        "grant_type": "client_credentials",
        "client_id": clientIdentifier,
        "client_secret": clientSecret,
        "scope": scopes,
      },
      options: Options(
        headers: {
          HttpHeaders.contentTypeHeader: "application/x-www-form-urlencoded",
          HttpHeaders.contentEncodingHeader: "utf-8",
        },
      ),
    );
    

    return auth as Client;
  }

I tried posting from post man where result is This.

0 Answers0