setAuthToken method

  1. @override
  2. @protected
  3. @visibleForTesting
void setAuthToken(
  1. String? token
)
override

Sets the authentication token under currentToken

In addition, updates RequestOptions's Authorization header formatted as:

TOKEN_HEADER + token

Implementation

@override
@protected
@visibleForTesting
void setAuthToken(String? token) {
  currentToken = token;

  // Can't use the standard Bearer <token> format since frappe treats that as something else
  // frappe/api.py validate_oauth() checks for the presence of the keyword 'Bearer'
  RenovationRequestOptions.headers!['Authorization'] = '$TOKEN_HEADER $token';
}