Skip to content

Authenticate

Authenticates the client using the specified service.

1
myRestClient.Authenticate(service: string):boolean

Authenticates the client using the specified service and scope.

1
myRestClient.Authenticate(service: string, scope: string):boolean

Authenticates the client using the specified service, scope, and identity.

1
myRestClient.Authenticate(service: string, scope: string, identity: ( string | Identity )):boolean

Parameters

string service
    The name of the service to authenticate with. Can be empty.

string scope
    The scope of the authentication context.

( string | Identity ) identity
    The identity to impersonate. Can be an Identity instance or its ID.

Returns

true if the authentication was successful; otherwise, false. true if the authentication was successful; otherwise, false. true if the authentication was successful; otherwise, false.

Remarks

If the service argument is empty, the client attempts to authenticate using HTTP Basic credentials from the domain settings.
The scope of authentication is based on the service parameter and may affect the security context of subsequent requests. Refer to the service documentation for details.
This method attempts server-to-server authentication if configured for the service. Otherwise, user consent must have been previously granted.
Use the RestClient.IsAuthenticated property to check the authentication status.

Example

1
2
3
4
5
6
7
8
9
var scopes = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';

var client = $Rest.Create('https://www.googleapis.com/oauth2/v2/userinfo');

if ( client.Authenticate('Google',scopes, $Initiator) ) {

  var userInfo = client.ExecuteJson();

}

If the service argument is empty, the client attempts to authenticate using HTTP Basic credentials from the domain settings.
The scope of authentication is based on the service parameter and may affect the security context of subsequent requests. Refer to the service documentation for details.
This method attempts server-to-server authentication if configured for the service. Otherwise, user consent must have been previously granted.
Use the RestClient.IsAuthenticated property to check the authentication status.

Example

1
2
3
4
5
6
7
8
9
var scopes = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';

var client = $Rest.Create('https://www.googleapis.com/oauth2/v2/userinfo');

if ( client.Authenticate('Google',scopes, $Initiator) ) {

  var userInfo = client.ExecuteJson();

}

If the service argument is empty, the client attempts to authenticate using HTTP Basic credentials from the domain settings.
The scope of authentication is based on the service parameter and may affect the security context of subsequent requests. Refer to the service documentation for details.
This method attempts server-to-server authentication if configured for the service. Otherwise, user consent must have been previously granted.
Use the RestClient.IsAuthenticated property to check the authentication status.

Example

1
2
3
4
5
6
7
8
9
var scopes = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';

var client = $Rest.Create('https://www.googleapis.com/oauth2/v2/userinfo');

if ( client.Authenticate('Google',scopes, $Initiator) ) {

  var userInfo = client.ExecuteJson();

}

See Also