@@ -172,43 +172,43 @@ |
||
| 172 | 172 | return; |
| 173 | 173 | } |
| 174 | 174 | switch ($_GET['response_type']) { |
| 175 | - case 'code': |
|
| 176 | - $Response->redirect( |
|
| 177 | - http_build_url( |
|
| 178 | - urldecode($redirect_uri), |
|
| 179 | - [ |
|
| 180 | - 'code' => $code, |
|
| 181 | - 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
| 182 | - ] |
|
| 183 | - ), |
|
| 184 | - 302 |
|
| 185 | - ); |
|
| 186 | - $Page->Content = ''; |
|
| 187 | - return; |
|
| 188 | - case 'token': |
|
| 189 | - $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], $redirect_uri); |
|
| 190 | - if ($token_data) { |
|
| 191 | - unset($token_data['refresh_token']); |
|
| 175 | + case 'code': |
|
| 192 | 176 | $Response->redirect( |
| 193 | - uri_for_token( |
|
| 194 | - http_build_url( |
|
| 195 | - urldecode($redirect_uri), |
|
| 196 | - array_merge( |
|
| 197 | - $token_data, |
|
| 198 | - [ |
|
| 199 | - 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
| 200 | - ] |
|
| 201 | - ) |
|
| 202 | - ) |
|
| 177 | + http_build_url( |
|
| 178 | + urldecode($redirect_uri), |
|
| 179 | + [ |
|
| 180 | + 'code' => $code, |
|
| 181 | + 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
| 182 | + ] |
|
| 203 | 183 | ), |
| 204 | 184 | 302 |
| 205 | 185 | ); |
| 206 | 186 | $Page->Content = ''; |
| 207 | 187 | return; |
| 208 | - } else { |
|
| 209 | - error_redirect('server_error', "Server can't get token data, try later"); |
|
| 210 | - return; |
|
| 211 | - } |
|
| 212 | - default: |
|
| 213 | - error_redirect('unsupported_response_type', 'Specified response_type is not supported, only "token" or "code" types available'); |
|
| 188 | + case 'token': |
|
| 189 | + $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], $redirect_uri); |
|
| 190 | + if ($token_data) { |
|
| 191 | + unset($token_data['refresh_token']); |
|
| 192 | + $Response->redirect( |
|
| 193 | + uri_for_token( |
|
| 194 | + http_build_url( |
|
| 195 | + urldecode($redirect_uri), |
|
| 196 | + array_merge( |
|
| 197 | + $token_data, |
|
| 198 | + [ |
|
| 199 | + 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
| 200 | + ] |
|
| 201 | + ) |
|
| 202 | + ) |
|
| 203 | + ), |
|
| 204 | + 302 |
|
| 205 | + ); |
|
| 206 | + $Page->Content = ''; |
|
| 207 | + return; |
|
| 208 | + } else { |
|
| 209 | + error_redirect('server_error', "Server can't get token data, try later"); |
|
| 210 | + return; |
|
| 211 | + } |
|
| 212 | + default: |
|
| 213 | + error_redirect('unsupported_response_type', 'Specified response_type is not supported, only "token" or "code" types available'); |
|
| 214 | 214 | } |