Overview
Authenticates the client from specified service with scope if not already authenticated and user and returns the client.RestClient RestClient.EnsureAuthenticated(service: string)
RestClient RestClient.EnsureAuthenticated(service: string, scope: string)
RestClient RestClient.EnsureAuthenticated(service: string, scope: string, identity: ( string | Identity ))
Arguments
Remarks
Identity is Id number of identity or Identity instance.
This method tries to server-to-server authentication if configured on service, otherwise user consent must be previously given.
If authentication failed error is thrown, use in try-catch block to act upon.
Example
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'); var result = client.EnsureAuthenticated('Google',scopes, $Initiator).ExecuteJson();
Remarks
Identity is Id number of identity or Identity instance.
This method tries to server-to-server authentication if configured on service, otherwise user consent must be previously given.
If authentication failed error is thrown, use in try-catch block to act upon.
Example
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'); var result = client.EnsureAuthenticated('Google',scopes, $Initiator).ExecuteJson();
Remarks
Identity is Id number of identity or Identity instance.
This method tries to server-to-server authentication if configured on service, otherwise user consent must be previously given.
If authentication failed error is thrown, use in try-catch block to act upon.
Example
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'); var result = client.EnsureAuthenticated('Google',scopes, $Initiator).ExecuteJson();
Examples
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'); var result = client.EnsureAuthenticated('Google',scopes, $Initiator).ExecuteJson();