/// <summary> /// Passes in client credential. If they have not expired, return them; otherwise, get and return a new set of client credentials. /// </summary> /// <param name="clientCredential">Client credentials.</param> /// <param name="scopeList">Scope list.</param> /// <returns></returns> public async Task <OAuthToken> GetClientCredentials(OAuthToken clientCredential, string scopeList) { if (clientCredential != null) { if (!clientCredential.IsExpired()) { return(clientCredential); } if (clientCredential.CreationTime > DateTime.Now.AddSeconds(ExpiredSeconds)) { return(await GetRefreshedClientCredential(clientCredential.RefreshToken)); } } return(await GetNewClientCredential(scopeList)); }