@@ -20,9 +20,16 @@ public class Client
20
20
/// <param name="token">Anon Key.</param>
21
21
/// <param name="options">Options</param>
22
22
/// <returns></returns>
23
- public static async Task < HttpContent > RawInvoke ( string url , string token , InvokeFunctionOptions options = null ) => ( await HandleRequest ( url , token , options ) ) . Content ;
23
+ public static async Task < HttpContent > RawInvoke ( string url , string token = null , InvokeFunctionOptions options = null ) => ( await HandleRequest ( url , token , options ) ) . Content ;
24
24
25
- public static async Task < string > Invoke ( string url , string token , InvokeFunctionOptions options = null )
25
+ /// <summary>
26
+ /// Invokes a function and returns the Text content of the response.
27
+ /// </summary>
28
+ /// <param name="url">Url of the function to invoke</param>
29
+ /// <param name="token">Anon Key.</param>
30
+ /// <param name="options">Options</param>
31
+ /// <returns></returns>
32
+ public static async Task < string > Invoke ( string url , string token = null , InvokeFunctionOptions options = null )
26
33
{
27
34
var response = await HandleRequest ( url , token , options ) ;
28
35
@@ -37,7 +44,7 @@ public static async Task<string> Invoke(string url, string token, InvokeFunction
37
44
/// <param name="token">Anon Key.</param>
38
45
/// <param name="options">Options</param>
39
46
/// <returns></returns>
40
- public static async Task < T > Invoke < T > ( string url , string token , InvokeFunctionOptions options = null )
47
+ public static async Task < T > Invoke < T > ( string url , string token = null , InvokeFunctionOptions options = null )
41
48
{
42
49
var response = await HandleRequest ( url , token , options ) ;
43
50
@@ -54,14 +61,18 @@ public static async Task<T> Invoke<T>(string url, string token, InvokeFunctionOp
54
61
/// <param name="options"></param>
55
62
/// <returns></returns>
56
63
/// <exception cref="RequestException"></exception>
57
- private static async Task < HttpResponseMessage > HandleRequest ( string url , string token , InvokeFunctionOptions options )
64
+ private static async Task < HttpResponseMessage > HandleRequest ( string url , string token = null , InvokeFunctionOptions options )
58
65
{
59
66
if ( options == null )
60
67
{
61
68
options = new InvokeFunctionOptions ( ) ;
62
69
}
63
70
64
- options . Headers [ "Authorization" ] = $ "Bearer { token } ";
71
+ if ( ! string . IsNullOrEmpty ( token ) )
72
+ {
73
+ options . Headers [ "Authorization" ] = $ "Bearer { token } ";
74
+ }
75
+
65
76
options . Headers [ "X-Client-Info" ] = Util . GetAssemblyVersion ( ) ;
66
77
67
78
var builder = new UriBuilder ( url ) ;
@@ -114,7 +125,7 @@ public RequestException(HttpResponseMessage response, ErrorResponse error) : bas
114
125
/// <summary>
115
126
/// Options that can be supplied to a function invocation.
116
127
///
117
- /// Note: If Headers.Authorization is set, it will later be overriden by the token supplied in the method call.
128
+ /// Note: If Headers.Authorization is set, it can be later overriden if a token is supplied in the method call.
118
129
/// </summary>
119
130
public class InvokeFunctionOptions
120
131
{
0 commit comments