API Integrator 2016 .NET Edition
API Integrator 2016 .NET Edition
Questions / Feedback?

BeforeOAuth Event

Fires before an OAuth authentication attempt begins.

Syntax

[VB.NET]
Public Event OnBeforeOAuth As OnBeforeOAuthHandler
[C#]
public event OnBeforeOAuthHandler OnBeforeOAuth;

public delegate void OnBeforeOAuthHandler(object sender, ApiclientBeforeOAuthEventArgs e);

class ApiclientBeforeOAuthEventArgs : EventArgs {
  int GrantType {get;}
  string ClientId {get;}
  string ClientSecret {get;}
  string ServerAuthURL {get;}
  string ServerTokenURL {get;}
  string AuthorizationScope {get;}
  string Token {get; set;}
  string RefreshToken {get; set;}
  long Timestamp {get; set;}
  long ExpiresIn {get; set;}
}

Remarks

This event will fire before every OAuth authentication attempt, allowing you to specify values for the component to use during the OAuth authentication process.

If OAuthCacheFile is set to a valid file path and contains values for Token, RefreshToken, or ExpiresIn, then the corresponding event parameters will be prefilled with the cached values.

If RefreshToken is populated and Token is set to an empty string, the component will attempt to refresh the OAuth token.

If Token is set and ExpiresIn is greater than 0, the component will attempt to use that token (regardless of whether or not RefreshToken is set).

A Timestamp is required, and is used in conjunction with the ExpiresIn value to determine whether or not the Token is still valid, or if a new Token should be acquired. Timestamp is specified in milliseconds since the Unix epoch, 00:00:00 UTC January 1, 1970. For instance "Tuesday, 19-Dec-17 21:06:21 UTC" would be "1513717581".

The GrantType will be prefilled with the value of the OAuthGrantType property.

After this event fires, the component will determine whether OAuth authorization is necessary based on the presence or absence of Token, RefreshToken, ExpiresIn, and Timestamp parameters.

If the current token is valid then no OAuth action occurs, and the AfterOAuth does not fire. If OAuth authentication is needed, then after the OAuth process completes, the AfterOAuth event will fire with the parameters used for during the process, as well as any returned parameters like RefreshToken.

 
 
Copyright (c) 2021 /n software inc. - All rights reserved.
API Integrator 2016 .NET Edition - Version 16.0 [Build 7709]