Skip to content

Commit cd95c16

Browse files
authored
Merge pull request #130 from akeneo/troubleshooting
Add a troubleshooting guide in the documentation
2 parents 3675c06 + c4a5dbe commit cd95c16

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

content/rest-api/security.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ curl -X POST http://your-host/api/oauth/v1/token \
159159
}'
160160
```
161161

162+
:::warning
163+
If you experience any error, please check the [troubleshooting guide](/documentation/troubleshooting.html#missing-client-id).
164+
:::
165+
162166
#### Example
163167

164168
**Request**

content/rest-api/troubleshooting.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Troubleshooting guide
2+
3+
This guide describes the most common errors you can experience when using the API and the solutions to fix them.
4+
5+
## Missing client id
6+
7+
Two problems can be the cause of the following response when authenticating to the API:
8+
9+
```json
10+
{
11+
"code": 422,
12+
"message": "Parameter "client_id" is missing or does not match any client, or secret is invalid"
13+
}
14+
```
15+
16+
### Base 64 not correctly encoded
17+
18+
You are not correctly encoding client and secret in base 64.
19+
We encourage you to use the [Postman collection](/getting-started-postman-collection.html) or the [PHP client](/php-client/introduction.html), that handle it automatically for you.
20+
21+
If you use the command line to generate the base 64, please ensure that you do it this way:
22+
23+
```bash
24+
echo -n "client_id:secret" | base64
25+
```
26+
27+
Do note the option `-n` to avoid to print the trailing newline character and encode it.
28+
29+
If you still experience the same error, please follow the second solution.
30+
31+
### Apache strip the authentication header
32+
33+
If you are sure to provide the correct base 64 of the client and secret, it probably means that Apache is not correctly set up.
34+
Various Apache modules can strip the authorization header “Authorization: Basic base64client_id:secret”.
35+
36+
Add the following line in your virtual host file:
37+
38+
```
39+
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
40+
```
41+
42+
## Redirection on connection page
43+
44+
When requesting the API, you are redirected to the API, with any endpoints.
45+
46+
This problem occurs when the project has been updated from version 1.6.
47+
It is coming from the security file `app/config/security.yml` in the PIM project.
48+
49+
The declaration order of the keys is important in this file.
50+
If the key `security.firewalls.main` is before the keys `security.firewalls.token`, `security.firewalls.api_index` and `security.firewalls.api`, you will be redirected on requesting page when using the API.
51+
52+
Please check that the keys under `security.firewalls` are in this following order:
53+
```
54+
oauth_token:
55+
pattern: ^/api/oauth/v1/token
56+
security: false
57+
58+
api_index:
59+
pattern: ^/api/rest/v1$
60+
security: false
61+
62+
api:
63+
pattern: ^/api
64+
fos_oauth: true
65+
stateless: true
66+
access_denied_handler: pim_api.security.access_denied_handler
67+
68+
main:
69+
pattern: ^/
70+
provider: chain_provider
71+
form_login:
72+
csrf_token_generator: security.csrf.token_manager
73+
check_path: oro_user_security_check
74+
login_path: oro_user_security_login
75+
logout:
76+
path: oro_user_security_logout
77+
remember_me:
78+
secret: "%secret%"
79+
name: BAPRM
80+
lifetime: 1209600 # stay logged for two weeks
81+
anonymous: false
82+
```
83+

src/getting-started.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@
143143
</code>
144144
</pre>
145145
<p>Well, this is your product. You made it, you made your first request!</p>
146+
<div class="alert alert-warning"><p>If you experienced any error, please check the <a href="/documentation/troubleshooting.html#missing-client-id">troubleshooting guide</a>.</p>
147+
</div>
146148
</div>
147149
</div>
148150
</div>

tasks/documentation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ gulp.task('documentation', ['clean-dist','less'], function () {
208208
'responses.md': 'Response codes',
209209
'pagination.md': 'Pagination',
210210
'update.md': 'Update behavior',
211-
'filter.md': 'Filters'
211+
'filter.md': 'Filters',
212+
'troubleshooting.md': 'Troubleshooting guide'
212213
};
213214

214215
return gulp.src('content/rest-api/*.md')

0 commit comments

Comments
 (0)