Advanced tasks > Using FileMaker ID for external authentication
 

Using FileMaker ID for external authentication

If you want to use the Claris FileMaker Data API or the OData API with FileMaker Cloud, you must authenticate using your FileMaker ID. FileMaker Cloud uses Amazon Cognito for external authentication.

Amazon Cognito manages users through user pools, which provide services such as sign-in, authentication with identity providers, user directory and profile management, and security monitoring. (See Amazon Cognito User Pools.)

To authenticate using FileMaker ID:

1. Retrieve values for the UserPoolId and ClientId parameters.

Amazon Cognito requires a UserPoolId and a ClientId to authenticate users. FileMaker Cloud provides the following endpoint:

https://www.ifmcloud.com/endpoint/userpool/
0.0.0.my.filemaker.com.jsonf

The endpoint returns the following results:

{
"errcode":"Ok",
"errmessage":null,
"data":{
"Region": "us-west-2",
"UserPool_ID":"us-west-2_NqkuZcXQY",
"Client_ID":"4l9rvl4mv5es1eep1qe97cautn",
"API_Host": "api-cloud-platform.ifmcloud.com",
"FCC_Host": "console.filemaker-cloud.com"
},
"csrid":null
}

Note  The returned Region and API_Host values are not used for authentication.

2. Use the Amazon Cognito Identity SDK for JavaScript to authenticate a user through Amazon Cognito. (See Amazon Cognito Identity SDK for JavaScript.) Use the example below in your JavaScript code to retrieve values for the FileMaker ID token (FileMaker_ID_token) and the FileMaker ID refresh token (FileMaker_ID_refresh_token).

The FileMaker ID token is used for authentication when you use the FileMaker Data API or OData API, and is valid for one hour. The FileMaker ID refresh token allows scripts to continue running after the FileMaker ID token expires, and is valid for one year.

Example

In this example:

the UserPool_ID and Client_ID values from above are used

for username and password, enter the FileMaker ID user name and password

Example code:

var authenticationData = {
Username : 'username',
Password : 'password',
};
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
var poolData = { UserPoolId : 'us-west-2_NqkuZcXQY',
ClientId : '4l9rvl4mv5es1eep1qe97cautn'
  };
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var userData = {
Username : 'username',
Pool : userPool
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
var Cognito_access_token = result.getAccessToken().getJwtToken();
var FileMaker_ID_token = result.idToken.jwtToken;
var FileMaker_ID_refresh_token = result.refreshToken.token;
},
onFailure: function(err) {
alert(err);
},
});