StringExtensionsMaskApiKey Method

Masks the API key present in the query string of a URL.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public static string MaskApiKey(
	this string url
)

Parameters

url  String
The input URL containing an API key as part of its query parameters. If the key exists, it will be replaced with "Google_API_Key".

Return Value

String
A new URL string with the API key masked. If the input URL does not contain a key or the input is null/whitespace, it returns the original URL.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also