loginWithNewScopes method

Future<OAuthToken> loginWithNewScopes(
  1. List<String> scopes, {
  2. String? nonce,
})

KO: 동의항목 추가 동의 요청
동의 항목 ID 목록은 scopes에 전달

EN: Request additional consent
Pass a list of the scope IDs to scopes

Implementation

Future<OAuthToken> loginWithNewScopes(
  List<String> scopes, {
  String? nonce,
}) async {
  if (kIsWeb) {
    throw KakaoClientException(
      ClientErrorCause.notSupported,
      'loginWithNewScopes() is not supported on web platform.',
    );
  }

  SdkLog.d(
    '[UserApi.loginWithNewScopes] started | scopeCount=${scopes.length} nonceProvided=${nonce != null}',
  );
  final redirectUri = KakaoSdk.redirectUri;
  final codeVerifier = generateRandomString(20);

  final authCode = await _authCodeClient.authorizeWithNewScopes(
    redirectUri: redirectUri,
    scopes: scopes,
    nonce: nonce,
    codeVerifier: codeVerifier,
  );
  final token = await _authApi.issueAccessToken(
    authCode: authCode,
    redirectUri: redirectUri,
    codeVerifier: codeVerifier,
  );
  await TokenManagerProvider.instance.manager.setToken(token);
  SdkLog.i(
    '[UserApi.loginWithNewScopes] completed | hasRefreshToken=${token.refreshToken != null}',
  );
  return token;
}