File tree Expand file tree Collapse file tree 6 files changed +127
-16
lines changed
sdk/server/php/public_html/att Expand file tree Collapse file tree 6 files changed +127
-16
lines changed Original file line number Diff line number Diff line change 34
34
echo $ response ;
35
35
}
36
36
catch (ServiceException $ se ) {
37
- return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
37
+ switch ($ se ->getErrorCode ()) {
38
+ case 400 : // invalid_grant. Invalid Refresh token.
39
+ case 401 : // UnAuthorized Access. Invalid access token.
40
+ unset($ _SESSION ['client_token ' ]);
41
+ if (DEBUG ) {
42
+ Debug::init ();
43
+ Debug::write ("Removed cached client token. Errocode= " . $ se ->getErrorCode () ."\n" );
44
+ Debug::end ();
45
+ }
46
+ break ;
47
+ }
48
+ return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
38
49
}
39
50
catch (Exception $ e ) {
40
- return_json_error (400 , $ e ->getMessage ());
51
+ $ error = $ e ->getMessage ();
52
+ // some operations in the codekit do not throw ServiceException
53
+ if (stripos ($ error , 'UnAuthorized Request ' ) !== false ) {
54
+ unset($ _SESSION ['client_token ' ]);
55
+ if (DEBUG ) {
56
+ Debug::init ();
57
+ Debug::write ("token removed. \n" );
58
+ Debug::end ();
59
+ }
60
+ return_json_error (401 , "UnAuthorized Request. Try again to obtain a new access token. " );
61
+ } else {
62
+ return_json_error (400 , $ error );
63
+ }
41
64
}
42
65
43
66
?>
Original file line number Diff line number Diff line change 128
128
echo $ response ;
129
129
}
130
130
catch (ServiceException $ se ) {
131
- return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
131
+ switch ($ se ->getErrorCode ()) {
132
+ case 400 : // invalid_grant. Invalid Refresh token.
133
+ case 401 : // UnAuthorized Access. Invalid access token.
134
+ unset($ _SESSION ['client_token ' ]);
135
+ if (DEBUG ) {
136
+ Debug::init ();
137
+ Debug::write ("Removed cached client token. Errocode= " . $ se ->getErrorCode () ."\n" );
138
+ Debug::end ();
139
+ }
140
+ break ;
141
+ }
142
+ return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
132
143
}
133
144
catch (Exception $ e ) {
134
- return_json_error (400 , $ e ->getMessage ());
145
+ $ error = $ e ->getMessage ();
146
+ // some operations in the codekit do not throw ServiceException
147
+ if (stripos ($ error , 'UnAuthorized Request ' ) !== false ) {
148
+ unset($ _SESSION ['client_token ' ]);
149
+ if (DEBUG ) {
150
+ Debug::init ();
151
+ Debug::write ("token removed. \n" );
152
+ Debug::end ();
153
+ }
154
+ return_json_error (401 , "UnAuthorized Request. Try again to obtain a new access token. " );
155
+ } else {
156
+ return_json_error (400 , $ error );
157
+ }
135
158
}
136
159
137
160
?>
Original file line number Diff line number Diff line change 236
236
echo $ response ;
237
237
}
238
238
catch (ServiceException $ se ) {
239
- return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
239
+ switch ($ se ->getErrorCode ()) {
240
+ case 400 : // invalid_grant. Invalid Refresh token.
241
+ case 401 : // UnAuthorized Access. Invalid access token.
242
+ unset($ _SESSION ['consent_tokens ' ]['MIM ' ]);
243
+ unset($ _SESSION ['consent_tokens ' ]['IMMN ' ]);
244
+ if (DEBUG ) {
245
+ Debug::init ();
246
+ Debug::write ("Removed cached client token. Errocode= " . $ se ->getErrorCode () ."\n" );
247
+ Debug::end ();
248
+ }
249
+ break ;
250
+ }
251
+ return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
240
252
}
241
253
catch (Exception $ e ) {
242
- return_json_error (400 , $ e ->getMessage ());
254
+ $ error = $ e ->getMessage ();
255
+ // some operations in the codekit do not throw ServiceException
256
+ if (stripos ($ error , 'UnAuthorized Request ' ) !== false ) {
257
+ unset($ _SESSION ['consent_tokens ' ]['MIM ' ]);
258
+ unset($ _SESSION ['consent_tokens ' ]['IMMN ' ]);
259
+ if (DEBUG ) {
260
+ Debug::init ();
261
+ Debug::write ("token removed. \n" );
262
+ Debug::end ();
263
+ }
264
+ return_json_error (401 , "UnAuthorized Request. Try again to obtain a new access token. " );
265
+ } else {
266
+ return_json_error (400 , $ error );
267
+ }
243
268
}
244
269
245
270
?>
Original file line number Diff line number Diff line change 56
56
echo $ response ;
57
57
}
58
58
catch (ServiceException $ se ) {
59
- return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
59
+ switch ($ se ->getErrorCode ()) {
60
+ case 400 : // invalid_grant. Invalid Refresh token.
61
+ case 401 : // UnAuthorized Access. Invalid access token.
62
+ unset($ _SESSION ['client_token ' ]);
63
+ if (DEBUG ) {
64
+ Debug::init ();
65
+ Debug::write ("Removed cached client token. Errocode= " . $ se ->getErrorCode () ."\n" );
66
+ Debug::end ();
67
+ }
68
+ break ;
69
+ }
70
+ return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
60
71
}
61
72
catch (Exception $ e ) {
62
- return_json_error (400 , $ e ->getMessage ());
73
+ $ error = $ e ->getMessage ();
74
+ // some operations in the codekit do not throw ServiceException
75
+ if (stripos ($ error , 'UnAuthorized Request ' ) !== false ) {
76
+ unset($ _SESSION ['client_token ' ]);
77
+ if (DEBUG ) {
78
+ Debug::init ();
79
+ Debug::write ("token removed. \n" );
80
+ Debug::end ();
81
+ }
82
+ return_json_error (401 , "UnAuthorized Request. Try again to obtain a new access token. " );
83
+ } else {
84
+ return_json_error (400 , $ error );
85
+ }
63
86
}
64
87
65
88
?>
Original file line number Diff line number Diff line change 85
85
echo $ response ;
86
86
}
87
87
catch (ServiceException $ se ) {
88
- return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
88
+ switch ($ se ->getErrorCode ()) {
89
+ case 400 : // invalid_grant. Invalid Refresh token.
90
+ case 401 : // UnAuthorized Access. Invalid access token.
91
+ unset($ _SESSION ['client_token ' ]);
92
+ if (DEBUG ) {
93
+ Debug::init ();
94
+ Debug::write ("Removed cached client token. Errocode= " . $ se ->getErrorCode () ."\n" );
95
+ Debug::end ();
96
+ }
97
+ break ;
98
+ }
99
+ return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
89
100
}
90
101
catch (Exception $ e ) {
91
- return_json_error (400 , $ e ->getMessage ());
102
+ $ error = $ e ->getMessage ();
103
+ // some operations in the codekit do not throw ServiceException
104
+ if (stripos ($ error , 'UnAuthorized Request ' ) !== false ) {
105
+ unset($ _SESSION ['client_token ' ]);
106
+ if (DEBUG ) {
107
+ Debug::init ();
108
+ Debug::write ("token removed. \n" );
109
+ Debug::end ();
110
+ }
111
+ return_json_error (401 , "UnAuthorized Request. Try again to obtain a new access token. " );
112
+ } else {
113
+ return_json_error (400 , $ error );
114
+ }
92
115
}
93
116
94
117
?>
Original file line number Diff line number Diff line change 86
86
switch ($ se ->getErrorCode ()) {
87
87
case 400 : // invalid_grant. Invalid Refresh token.
88
88
case 401 : // UnAuthorized Access. Invalid access token.
89
- case 403 : // Forbidden - app-key secret might have been chnaged in between
90
89
unset($ _SESSION ['client_token ' ]);
91
90
if (DEBUG ) {
92
91
Debug::init ();
98
97
return_json_error ($ se ->getErrorCode (), $ se ->getErrorResponse ());
99
98
}
100
99
catch (Exception $ e ) {
101
- if (DEBUG ) {
102
- Debug::init ();
103
- Debug::write ("Error code: " .$ e ->getCode ()." ErrorMessage: " .$ e ->getMessage ());
104
- Debug::end ();
105
- }
106
100
$ error = $ e ->getMessage ();
107
101
// some operations in the codekit do not throw ServiceException
108
102
if (stripos ($ error , 'UnAuthorized Request ' ) !== false ) {
You can’t perform that action at this time.
0 commit comments