Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for creating and revoking personal access tokens and fetching health check tokens. #336

Closed
gmessner opened this issue May 1, 2019 · 11 comments

Comments

@gmessner
Copy link
Collaborator

gmessner commented May 1, 2019

The GitLab API does not support the creation or revocation of personal access tokens, this makes it difficult to automate the testing of GitLab4J-API without a pre-configured and data seeded GitLab server running.

Adding the ability to create and revoke personal access tokens and fetch health check tokens will allow for the full automation of GitLab4J-API using the gitlab-ce docker image.

@gmessner
Copy link
Collaborator Author

gmessner commented May 2, 2019

This functionality has been released in 4.10.8

@gmessner gmessner closed this as completed May 2, 2019
@baymac
Copy link
Contributor

baymac commented May 30, 2019

Thank you @gmessner for implementing this functionality.

@baymac
Copy link
Contributor

baymac commented May 30, 2019

I would like add a suggestion. If we can add static variable inside the AccessTokenUtils class so that the scope names can be clear. Avoids confusion for user.

For example,

public static final String API = "api";
public static final String READ_USER = "read_user";
public static final String READ_REPOSITORY = "read_repository";
...

I feel it could help users understand which variables to supply rather than checking them on GitLab Server. If you want to do this let me know, I will send PR. If you have a better suggestion also let me know. @gmessner

@gmessner
Copy link
Collaborator Author

@baymac
I would prefer these to be an enum. I am actually doing a release today so will add this enum. Will let you know when it is done.

@baymac
Copy link
Contributor

baymac commented May 30, 2019

@gmessner yes, I found enum defined inside Constants. Presently I am using that but perhaps it could be improved. I would prefer enums inside AccessTokenUtils. Waiting for your release!

@gmessner
Copy link
Collaborator Author

@baymac
The ApplicationScope is a different thing, I will be adding a Scope enum to the AccessTokenUtils class. Should have this released shortly.

@gmessner gmessner reopened this May 31, 2019
@baymac
Copy link
Contributor

baymac commented May 31, 2019

@gmessner I used it as

List<String> GL_PLUGIN_REQUIRED_SCOPE = ImmutableList.of(
    Constants.ApplicationScope.API.toValue(), // api
    Constants.ApplicationScope.READ_USER.toValue() // read_user
);

And it works like that. Btw what is the actual purpose of ApplicationScope?

@gmessner
Copy link
Collaborator Author

@baymac
ApplicationScope is for setting the scope of an OAUTH2 application, see ApplicationsApi.

@baymac
Copy link
Contributor

baymac commented May 31, 2019

Got it. Thanks. @gmessner

gmessner added a commit that referenced this issue May 31, 2019
@gmessner
Copy link
Collaborator Author

gmessner commented May 31, 2019

@baymac
The Scope enum has been added to AccessTokenUtils and is available in release 4.11.4.

Just a heads up, the createAccessToken() method no longer takes List<String>, it is now List<Scope>

@baymac
Copy link
Contributor

baymac commented May 31, 2019

Awesome. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants