Authorize
After creating your API Key, you are ready to make API calls. Most clients set up authentication when initializing the client, it can be changed for particular requests if needed. If you are using the REST API, you will need to add the Authorization header as described in the cURL example.
js
python
java
csharp
objective-c
php
cURL
1
// Authentication done at gRPC stub initialization time see:
2
//
3
https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
4
metadata.set("authorization", "Key YOUR_CLARIFAI_API_KEY");
Copied!
1
metadata = (('authorization', 'Key YOUR_API_KEY'),)
2
# Yes the word 'Key' appears in addition to the alphanumeric API_KEY
Copied!
1
// Authentication done at grpc stub initialization time see:
2
//
3
https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
4
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
5
.withCallCredentials(new ClarifaiCallCredentials("YOUR_CLARIFAI_API_KEY"));
Copied!
1
using System.Threading.Tasks;
2
using Clarifai.API;
3
4
namespace YourNamespace
5
{
6
public class YourClassName
7
{
8
public static async Task Main()
9
{
10
var client = new ClarifaiClient("YOUR_API_KEY");
11
}
12
}
13
}
Copied!
1
ClarifaiApp *app = [[ClarifaiApp alloc] initWithApiKey:@"YOUR_API_KEY"];
Copied!
1
use Clarifai\API\ClarifaiClient;
2
3
$client = new ClarifaiClient('YOUR_API_KEY');
Copied!
1
curl -X POST \
2
-H 'Authorization: Key YOUR_API_KEY' \
3
-H "Content-Type: application/json" \
4
-d '
Copied!
If the API Key does not have the required scope(s) to execute a given request, you will get an error message reporting the missing scopes and/or endpoints that your key needs to execute this request. An invalid key may be reported as 'API key not found'. Failure to include a required key may result simple in 'Invalid request'.
Last modified 17d ago
Copy link