OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Docs: Adding outh authentication code flow example
Wieland Lindenthal2748d3211ede
diff --git a/docs/system-admin-guide/authentication/oauth-applications/README.md b/docs/system-admin-guide/authentication/oauth-applications/README.mdindex 53a746d4ccb..786818d617a 100644--- a/docs/system-admin-guide/authentication/oauth-applications/README.md+++ b/docs/system-admin-guide/authentication/oauth-applications/README.md@@ -23,11 +23,13 @@ You can configure the following options to add your oauth application.1. Enter the **name** of your oauth application.2. **Define redirect URLs** where authorized users can be redirected to.3. Check if the application will be used **confidentially**.-4. Choose **client credential flows** and define a user on whose behalf requests will be performed.+4. (Optional) Choose **client credential flows** and define a user on whose behalf requests will be performed.5. Press the blue **Create** button to add your oauth application.+Don't forget to note down your `Client ID` and your `Client secret` in a safe space. You will need it later.+## Oauth endpointsThe authentication endpoints are at@@ -35,11 +37,62 @@ The authentication endpoints are at* Auth URL: `https://example.com/oauth/authorize`* Access Token URL: `https://example.com/oauth/token`-## Performing request to the OpenProject API with OAuth token+## **Authorization code flow** example++### Requesting authorization code++Request an authorization code. Please adopt the following URL replacing++ * the `example.com` with the root path of your OpenProject instance,+ * `<Client ID>` with your client ID, and+ * `<Redirect URI>` with the redirect URI just as you configured it above.+ * You can leave the `scope` value untouched unless you are running the OpenProject BIM edition and also plan to access to the BCF version 2.1 REST API. Then simply replace `api_v3` with `api_v3%20bcf_v2_1`.++`https://example.com/oauth/authorize?response_type=code&client_id=<Client ID>&redirect_uri=<Redirect URI>&scope=api_v3&prompt=consent`++That requests redirects you to a URL that holds a `code` parameter which is the authentication code.++Typically the server that was requested with that redirect will save the authorization code and use it+to obtain an API token, with which the server can then act on behalf of the current user.++In this example we skip that server side implementation and just copy the value of the `code` parameter from the URL that you see in your browser.++### Requesting API token++With the authorization code that you obtained above you can now request an API token.++We do this manually in the command line using cURL. Please replace++ * the `example.com` with the root path of your OpenProject instance,+ * `<Client ID>` with your client ID+ * `<Authentication code>` with the code you obtained above,+ * and `<Redirect URI>` with the redirect URI just as you configured it above.++```+$ curl --request POST \+ --url 'https://example.com/oauth/token' \+ --header 'content-type: application/x-www-form-urlencoded' \+ --data grant_type=authorization_code \+ --data client_id=<Client ID> \+ --data client_secret=<Client secret> \+ --data code=<Authentication code> \+ --data 'redirect_uri=<Redirect URI>'+```++The response will contain the token that you need when working with the API. Please copy the token.++### Performing a request to the OpenProject API with OAuth token++With the token that you obtained above you can now make API calls to the OpenProject instance+on behalf of the current user.-The following CURL command fetches all projects from the API V3:+For example, the following cURL command fetches all projects from the API V3. Please replace++ * the `example.com` with the root path of your OpenProject instance, and+ * `<Token>` with the code you obtained above.-`curl --location --request GET 'https://example.com/api/v3/projects' --header 'Authorization: Bearer <your-access-token>'`+`$ curl --request GET 'https://example.com/api/v3/projects' \+ --header 'Authorization: Bearer <Token>'`## Using Postman with oauth?