private async Task GetAuthTokensAsync(string code, string realmId) { oAuth2Client = new OAuth2Client(OAuth2Keys.ClientId, OAuth2Keys.ClientSecret, OAuth2Keys.RedirectUrl, OAuth2Keys.Environment); var tokenResponse = await oAuth2Client.GetBearerTokenAsync(code); OAuth2Keys.RealmId = realmId; Token token = _tokens.Token.FirstOrDefault(t => t.RealmId == realmId); if (token == null) { _tokens.Add(new Token { RealmId = realmId, AccessToken = tokenResponse.AccessToken, RefreshToken = tokenResponse.RefreshToken }); await _tokens.SaveChangesAsync(); } }
public Guid Post(string tenantId, string url, string groupId, string mail) { var GUID = Guid.NewGuid(); var token = new Token { GUID = GUID, TenantId = tenantId, Url = url, GroupId = groupId, Mail = mail }; db.Add(token); try { db.SaveChanges(); return(GUID); } catch (Exception ex) { throw new Exception("Error in save data to database" + ex.Message); } }