JGIT - Get every authorized private project - java

I'm trying to get every project that a given user is authorized to "see". For example, when I log into my GitLab account i'm able to choose (from the dashboard) which project I want to explore.
So, what I need is to get that "list" dynamically with Jgit in order to show it to the user that's logged in my webapp.
Is it possible to do it using JGit? Or should I use the GIT-API?

The GIT-API you mention (https://developer.github.com/v3/) is for GitHub, not GitLab.
For GitLab, you should use https://docs.gitlab.com/ce/api/.
Listing the projects accesible by a user was requested in gitlab-ce issue 33657 and implemented with gitlab-ce merge_request 12596 in commit 050eae8
GET /users/:user_id/projects
You don't need JGit, but a GitLAb API wrapper in Java like gmessner/gitlab4j-api.

Related

Using two Google APIs with the same application

I have an application which connects to Google Drive API.
Now I have to add another function which requires the Google Directory API.
I granted the necessary permissions and enabled the new API in my project.
However I'm still getting this error:
"message" : "Access Not Configured. Admin Directory API has not been
used in project 594418282793 before or it is disabled. Enable it by
visiting
https://console.developers.google.com/apis/api/admin.googleapis.com/overview?project=594418282793
then retry. If you enabled this API recently, wait a few minutes for
the action to propagate to our systems and retry."
The problem is that the URL in the message gives me an error; apparently the project ID is invalid.
This is the error:
There was an error while loading
/apis/dashboard?project=594418282793. You are missing at least one of
the following required permissions:
Project
resourcemanager.projects.get
Check that the project ID is valid and you have permissions to access
it.
I have no idea what is the cause of this mismatch, why the project ID provided in the error message doesn't seem to exist, and where else should I enable the second API in my application.
Any ideas would be much appreciated.
I think you have miss understood how the credentials.json works.
Access Not Configured.
Means that the credentials you have loaded for this client has not been setup for the api you are trying to connect to.
When you create a project on Google developer console this is to give google information about your application as a whole and what it is designed to do. You should enable both apis in the single project.
Once that is done create your Oauth credentials as you did before this credential file will then be able to connect to both apis .
googel developer console
Left hand menu click credentials then button on the top says create credentials
Once you have created it click the arrow to download you can download the file anytime

google app engine deploy to two difference accounts from same machine

Using the google app engine maven plugin when a deploy is performed, the browser opens and an oauth key is copied.
However, I want to use two different google accounts from the same laptop and have laready previously registered one oauth key, but now want to use another. I never get prompted for a key and the deploy fails as the application id is not correct, which is expected.
Is there any way to use two different google accounts with app engine sdk ?
I can deploy the app OK using a different machine as it is setup with the correct account.
(this would not be a problem if push to deploy/pipeline worked, but it doesn't)
To have more than one account register with the SDK, you should use gcloud Command Line Tool.
Once you have login multiple accounts, $ gcloud auth list should yield a list of accounts. Switching is as simple as running $ gcloud config set account ``ACCOUNT'' which should make relevant tokens active and will allow you to use appcfg.[py|sh] with the selected account.
If you look in your home directory, you should find a couple of files used by appcfg: .appcfg_oauth2_tokens_java and .appcfg_cookies. Deleting the former (I think) will prompt appcfg to retrigger the oauth process.
So... I guess if you have multiple oauth token files, you can create a short shell script that takes the username as an argument then copies the oauth token file you need to .appcfg_oauth2_tokens_java just before the appcfg update.

How to handle credentials in an open source project

I have developed an application that lives in a public Github repository.
The app interacts with systems that require credentials that are currently stored in a properties file.
A jenkins box runs the app periodically.
The problem of saving the project in github without exposing my credentials is succinctly addressed here.
How do I pass my credentials to the jenkins job without exposing the credentials (needed by the app) to my workmates?
In my case I went for a jenkins parametrized build that allowed me to provide string and password type of params.
The params are read in the program via system.getProperty

Authenticate subversion remotely

I'm developing an application based on java which allows one to manage jenkins jobs remotely.
How can I insert svn user and password when creating a new job?
I am not aware of any method of doing so, however you can have the master cache credentials after authenticating successfully once.
This can be found under: Manage Jenkins>Configure System>Subversion. Just check the box which specifies "Update default Subversion credentials cache after successful authentication".
If you have multiple repositories this won't help, but if your jobs use the same repo then you should be able to create a new job via the api without explicitly specifying the SVN credentials.

Hudson project without user interface

Can I configure, create/update the existing project in Hudson without using its user interface?
Is it possible by changing configuration file or other mean?
The Remote Access API page mentions that you an create/copy job with it.
Remote access API is offered in a REST-like style.
That is, there is no single entry point for all features, and instead they are available under the ".../api/" URL where "..." portion is the data that it acts on.
For example, if your Hudson installation sits at http://deadlock.netbeans.org/hudson/, http://deadlock.netbeans.org/hudson/api/ will give you HTML lists of all available functionality that act on the Hudson root.
On my Hudson, the /api address gives:
Create Job
To create a new job, post config.xml to this URL with query parameter name=JOBNAME.
You'll get 200 status code if the creation is successful, or 4xx/5xx code if it fails.
config.xml is the format Hudson uses to store the project in the file system, so you can see examples of them in /server/path/to/your/hudson/home.

Categories

Resources