private void InitNoScopeAdapters() { var secondPartyAppInfo = GetDefaultApplication(ApplicationType.SecondParty); var secondPartyConnection = new PublicAPIConnection(secondPartyAppInfo.Key, secondPartyAppInfo.Secret); Dictionary <string, string> oauthParams = new Dictionary <string, string>(); oauthParams.Add("scope", string.Empty); oauthParams.Add("app_id", secondPartyAppInfo.Key); oauthParams.Add("response_type", "code_direct"); secondPartyConnection.Authentication.Authenticate(oauthParams); _secondPartyApplicationAdapter = PublicApiAdapter.CreateAdapter(secondPartyConnection, secondPartyAppInfo.Company.Partition); var thirdPartyAppInfo = GetDefaultApplication(ApplicationType.ThirdParty); var thirdPartyConnection = new PublicAPIConnection(thirdPartyAppInfo.Key, thirdPartyAppInfo.Secret); var subscriber = new ApplicationSubscriber(); Assume.That(subscriber.Subscribe(thirdPartyAppInfo.Key, thirdPartyAppInfo.Metadata["redirectUrl"].ToString(), "client_d", AuthenticationInfoProvider.Current.DefaultCompanyName, // client_d does not affect read/write operations. We use it as a workaround for empty scope AuthenticationInfoProvider.Current.DefaultUserLogin, AuthenticationInfoProvider.Current.DefaultUserPassword), Is.EqualTo(AuthResponseCode.Success), "Couldn't get oauth code for 3rd party application"); var tokenApi = new TokenAPI { AccessHelper = new PublicAPIConnection(thirdPartyAppInfo.Key, thirdPartyAppInfo.Secret) }; var tokenResponse = tokenApi.AccessTokenSuccess(thirdPartyAppInfo.Key, "oauth_code", thirdPartyAppInfo.Secret, subscriber.ResultOauthCode); Assume.That(tokenResponse.AccessToken, Is.Not.Null, "get token request for 3rd party application was not successful"); thirdPartyConnection.Authentication.Token = tokenResponse.AccessToken; _thirdPartyApplicationAdapter = PublicApiAdapter.CreateAdapter(thirdPartyConnection, thirdPartyAppInfo.Company.Partition); }
private void InitScopeAdapter(string scope, ApplicationType appType) { appInfo = GetDefaultApplication(appType); var connection = new PublicAPIConnection(appInfo.Key, appInfo.Secret); var subscriber = new ApplicationSubscriber(); Assume.That(subscriber.Subscribe(appInfo.Key, appInfo.Metadata["redirectUrl"].ToString(), scope, AuthenticationInfoProvider.Current.DefaultCompanyName, AuthenticationInfoProvider.Current.DefaultUserLogin, AuthenticationInfoProvider.Current.DefaultUserPassword), Is.EqualTo(AuthResponseCode.Success)); _testCleanupActions.Add(() => subscriber.Unsubscribe(appInfo.Key, appInfo.Metadata["redirectUrl"].ToString(), scope, AuthenticationInfoProvider.Current.DefaultCompanyName, AuthenticationInfoProvider.Current.DefaultUserLogin, AuthenticationInfoProvider.Current.DefaultUserPassword)); var tokenApi = new TokenAPI { AccessHelper = new PublicAPIConnection(appInfo.Key, appInfo.Secret) }; var tokenResponse = tokenApi.AccessTokenSuccess(appInfo.Key, "oauth_code", appInfo.Secret, subscriber.ResultOauthCode); Assume.That(tokenResponse.AccessToken, Is.Not.Null); connection.Authentication.Token = tokenResponse.AccessToken; adapter = PublicApiAdapter.CreateAdapter(connection, appInfo.Company.Partition); }
private PublicAPIConnection PreparePublicApiConnection(string contentTypeHeaderValue) { var connection = new PublicAPIConnection(); var code = new OAuthAPI().GetCodeSuccess(AuthenticationInfoProvider.Current.DefaultAppKey, "code_direct").Code; var token = new TokenAPI().AccessTokenSuccess(AuthenticationInfoProvider.Current.DefaultAppKey, "oauth_code", AuthenticationInfoProvider.Current.DefaultAppSecret, code).AccessToken; connection.Authentication.Token = token; connection.Headers["Content-Type"] = contentTypeHeaderValue; return(connection); }
public void TestAuthenticationAPIs() { OAuthAPI api = new OAuthAPI(); TokenAPI tokenApi = new TokenAPI(); Authentication authentication = api.GetCodeSuccess(AuthenticationInfoProvider.Current.DefaultAppKey, "code_direct"); Assert.That(authentication, Is.Not.Null, "Cannot access to OAuth API"); authentication = tokenApi.AccessTokenSuccess(AuthenticationInfoProvider.Current.DefaultAppKey, "oauth_code", AuthenticationInfoProvider.Current.DefaultAppSecret, authentication.Code); Assert.That(authentication, Is.Not.Null, "Cannot access to Token API"); Assert.That(authentication.Error, Is.EqualTo(Enums.PublicAPIResultCode.Success.ToString()), "Getting token is not successful!"); Assert.That(authentication.AccessToken, Is.Not.Null.And.Not.Empty, "AccessToken is null or empty"); }
public void InitHelpers(ApplicationType appType) { var appInfo = GetDefaultApplication(appType); oAuthAPI = new OAuthAPI() { AccessHelper = new PublicAPIConnection(appInfo.Key, appInfo.Secret) { IsAutoRefreshToken = false } }; tokenAPI = new TokenAPI() { AccessHelper = oAuthAPI.AccessHelper }; }
public void InitApiHelpers(ApplicationType appType) { Log.Info("Starting the test of Oauth!"); var appInfo = GetDefaultApplication(appType); oAuthAPI = new OAuthAPI() { AccessHelper = new PublicAPIConnection(appInfo.Key, appInfo.Secret) { IsAutoRefreshToken = false } }; tokenAPI = new TokenAPI() { AccessHelper = oAuthAPI.AccessHelper }; }
private PublicApiAdapter CreateThirdPartyAppAdapter(bool isReadApp) { var thirdPartyAppInfo = GetDefaultApplication(ApplicationType.ThirdParty, isReadApp); var thirdPartyConnection = new PublicAPIConnection(thirdPartyAppInfo.Key, thirdPartyAppInfo.Secret); var subscriber = new ApplicationSubscriber(); Assume.That(subscriber.Subscribe(thirdPartyAppInfo.Key, thirdPartyAppInfo.Metadata["redirectUrl"].ToString(), isReadApp ? ReadOnlyScope : WriteOnlyScope, AuthenticationInfoProvider.Current.DefaultCompanyName, AuthenticationInfoProvider.Current.DefaultUserLogin, AuthenticationInfoProvider.Current.DefaultUserPassword), Is.EqualTo(AuthResponseCode.Success), "Couldn't get oauth code for 3rd party application"); var tokenApi = new TokenAPI { AccessHelper = new PublicAPIConnection(thirdPartyAppInfo.Key, thirdPartyAppInfo.Secret) }; var tokenResponse = tokenApi.AccessTokenSuccess(thirdPartyAppInfo.Key, "oauth_code", thirdPartyAppInfo.Secret, subscriber.ResultOauthCode); Assume.That(tokenResponse.AccessToken, Is.Not.Null, "get token request for 3rd party application was not successful"); thirdPartyConnection.Authentication.Token = tokenResponse.AccessToken; return(PublicApiAdapter.CreateAdapter(thirdPartyConnection, thirdPartyAppInfo.Company.Partition)); }
public IActionResult Login(string email, string password) { User user = new User(); SessionAPI session = new SessionAPI(); try { user = _dataRepository.Get(email, password); if (user == null) { return(StatusCode(202, "Unable to process request")); } session.Email = email; session.Name = user.username; session.Token = TokenAPI.GetToken(user.id.ToString()); return(Ok(session)); } catch (Exception ex) { return(StatusCode(500, "Unable to process request")); } }
public IssueListViewModel() { if (Issues == null) { Issues = new ObservableCollection <AddIssueViewModel>(); } Task.Run(async() => { try { var issues = new List <Models.Issues>(); issues.Add(new Models.Issues { IssueId = 7, IssuesTitle = "asdf", IssuesStatusesTitle = "Open" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "In progress" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Invalid" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "In progress" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Open" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "In progress" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Open" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Open" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Solved" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); //var issues = await _issuesAPI //.GetIssues(Application.Current.Properties["token"].ToString()); foreach (var issue in issues) { var i = new AddIssueViewModel { IssueId = issue.IssueId, //IssuesCategoriesId = issue.IssuesCategoriesId, //IssuesDescription = issue.IssuesDescription, //IssuesExpectedBehavior = issue.IssuesExpectedBehavior, //IssuesPriorityId = issue.IssuesPriorityId, //IssuesProjectsId = issue.IssuesProjectsId, //IssuesSeverityId = issue.IssuesSeverityId, //AttachmentsView = issue.AttachmentsView, //Comments = issue.Comments, //IssuesStatusesId = issue.IssuesStatusesId, IssuesStatusesTitle = issue.IssuesStatusesTitle, IssuesTitle = issue.IssuesTitle }; i.StatusColor = IssueStatusColor(i.IssuesStatusesTitle); Issues.Add(i); } } catch (Exception) { } }); SearchCommand = new Command(async() => { try { if (TokenAPI.CheckTokenValidation(Application.Current.Properties["token"].ToString())) { Issues.Clear(); //var issues = await _issuesAPI //.SearchIssues(Application.Current.Properties["token"].ToString(), EntryContext); var issues = new List <Models.Issues>(); issues.Add(new Models.Issues { IssuesTitle = "asdf3", IssuesStatusesTitle = "Invalid" }); issues.Add(new Models.Issues { IssuesTitle = "asdf3", IssuesStatusesTitle = "In progress" }); issues.Add(new Models.Issues { IssuesTitle = "a2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Open" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "In progress" }); issues.Add(new Models.Issues { IssuesTitle = "asdf2", IssuesStatusesTitle = "Close" }); foreach (var issue in issues) { var i = new AddIssueViewModel { IssueId = issue.IssueId, //IssuesCategoriesId = issue.IssuesCategoriesId, //IssuesDescription = issue.IssuesDescription, //IssuesExpectedBehavior = issue.IssuesExpectedBehavior, //IssuesPriorityId = issue.IssuesPriorityId, //IssuesProjectsId = issue.IssuesProjectsId, //IssuesSeverityId = issue.IssuesSeverityId, //AttachmentsView = issue.AttachmentsView, //Comments = issue.Comments, //IssuesStatusesId = issue.IssuesStatusesId, IssuesStatusesTitle = issue.IssuesStatusesTitle, IssuesTitle = issue.IssuesTitle }; i.StatusColor = IssueStatusColor(i.IssuesStatusesTitle); Issues.Add(i); } } } catch (Exception) { } }); }