Authorization url gives me 404 and cors
daav7713 opened this issue · 5 comments
This is an intentional security feature of our authentication flow (and OAuth in general). It would be bad if Javascript were able to access the authorization page without the user's knowledge.
In order to complete the OAuth 1 flow, you must direct the browser itself, not an AJAX request, to the authorization URL. Once the user authorizes your app, we will redirect the browser back to the callback URL you registered, per the standard OAuth 1.0/a flow, which you can read about more here (or Google around, there are plenty of articles :) )
Hope this helps!
Hello, the error occurs when I am trying to redirect the user to the authorization page when I have already obtained the request token through an oauth1 library called RISAN, with php, I am not making any ajax request or using javascript.
// this is my code
$signer = new Risan\OAuth1\Signature\HmacSha1Signer();
$oauth1 = Risan\OAuth1\OAuth1Factory::create([
'client_credentials_identifier' => $this->consumer_key,
'client_credentials_secret' => $this->consumer_secret,
'temporary_credentials_uri' => 'https://secure.splitwise.com/oauth/request_token',
'authorization_uri' => 'https://secure.splitwise.com/oauth/authorize',
'token_credentials_uri' => 'https://secure.splitwise.com/oauth/access_token',
'callback_uri' => $this->consumer_callback,
],$signer);
//
$temporaryCredentials = $oauth1->requestTemporaryCredentials();
// Store the temporary credentials in session.
$_SESSION['temporary_credentials'] = serialize($temporaryCredentials);
// // STEP 2: Generate and redirect user to authorization URI.
$authorizationUri = $oauth1->buildAuthorizationUri($temporaryCredentials);
// var_dump($authorizationUri);
header("Location: {$authorizationUri}");
//header("LOCATION: http://www.google.com"); exit();
exit();
@daav7713 I understand that your PHP server may be redirecting clients to the authorization URI, but in this case the client appears to be an XMLHttpRequest, which is why you're getting that CORS error. I'm happy to help if our OAuth flow is broken, but unfortunately I can't help debug your application.
