Specify QueryString Parameters in redirect_uri - asp.net-mvc

I have implemented Signup with facebook functionality, its working fine, now I have to specify a parameter in redirect_uri, I have specified it but when I am accessing FB, Its giving error:
(OAuthException) Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
If my redirect_uri is this
http://localhost:5000/SignUp/FBOAuth
it works fine,but when I specify parameter like this(this parameter can have null value)
http://localhost:5000/SignUp/FBOAuth?CheckOut=
or
http://localhost:5000/SignUp/FBOAuth?CheckOut=
It starts giving error, Is it possible to specify parameters in redirect_uri? I have read on facebook developer's site that its a bug, Here

Related

Missing authorization code error in Google OAuth2

I'm stuck with an issue while trying to use Google's OAuth2 php lib. On the server side, after I instantiate an OAuth2 object I redirect the user to Google's sign in page, after which they hopefully grant permissions based on the scopes (the APIs I declared for use in the OAuth2) I declared. Now here's my issue: after the user grants permission I get redirected to the redirectUri I specified during the instantiation of OAuth2. This redirectUri contains as params state, code, and scope k-v pairs. I always get a "Missing authorization code" if I don't send back the value code to server and set it as a property of the OAuth2 object. However, if I send back the value of code to the server and set it as a property of the OAuth2 object I get a
"Client error: POST https://www.googleapis.com/oauth2/v4/token
resulted in a 400 bad request response. Error: "invalid_grant"`
So, I'm at lost here. I should mention that I actually managed to make 2 authorized calls to Google Ad Manager (the scope I declared) using the same flow I described above, but after that I keep getting the same 2 errors as above.
Does anybody know what's going on? I must be missing something but I can't see what. I'm using this guide so it's not really convoluted or complicated code but I just can't get it to work somehow. https://github.com/googleads/googleads-php-lib/wiki/API-access-on-behalf-of-your-clients-(web-flow)

Microsoft Azure Directory oAuth redirect_uri not accepting state query parameter

I'm trying to implement the oAuth flow to sign in with Microsoft.
I have the following endpoints:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
https://login.microsoftonline.com/common/oauth2/v2.0/token
My flow is like this:
Redirect to Microsoft by clicking on Sign in with Microsoft button:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id={client_id}&scope=user.read&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F1%2Ffrontend%2Flogin%3Fstate%3Dtest
My redirect url is:
http://localhost:8000/1/frontend/login?state=test
Which is appended with the code I receive back from Microsoft.
I then perform a POST request to the /token endpoint.
However, I receive an error (AADSTS50011) saying:
AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application:
The data I send is correct, except for the redirect_uri. I have the following value:
http%3A%2F%2Flocalhost%3A8000%2F1%2Ffrontend%2Flogin%3Fstate%3Dtest
Which is just an url encoded version of my redirect url including the ?state=test
I know that everything works fine, except the redirect_uri, because when I remove the state query param, everything works fine.
However, to route the redirect_uri correctly in my application, I need the state param.
I cannot add it in my App settings, and I have to include it in the first request (/authorize endpoint)
That all works fine, but the second (/token) POST request fails, I cannot enter my redirect_uri with the ?state= parameter.
I've tried several options such as encoding the redirect_uri, but it doesn't help.
All other oAuth flows (Like Github) are working fine. Except Microsoft.
Attach your state param to the auth request itself, don’t put it in the redirect_uri param. Then the state param is automatically sent back to the redirect uri.
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id={client_id}&scope=user.read&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F1%2Ffrontend%2Flogin&state=xyz

Dailymotion Callback URL Error

I am trying to connect to the Data-API by using the PHP-SDK.
I have configured an API-Key. But when trying to connect an exception is thrown. Message:
This redirect_uri' isn't allowed byclient_id' configuration.
I suppose that somehow the callback URL is not correct.
Any help is appreciated.
Regarding the redirect_uri, if is stated at https://github.com/dailymotion/dailymotion-sdk-php/blob/master/Dailymotion.php#L196 that:
"if using authorization grant type, this key can be provided. If omitted, the current URL will be used. Make sure this value stays the same before the user is redirect to the authorization page and after the authorization page redirects to this URI (the token server will change this)."
You should also make sure that this value matches the "callback url" you defined when creating the api key at http://www.dailymotion.com/settings/developer . It not matching, it will trigger the error you mentioned.

Twitter API oAuth failed signature when adding callback url

I'm using this code/guide another twitter oAuth cURL access token request that fails to test signing my request to the API. I'm still trying to go through step 1 of this
Note: the keys are just random, they're not real :)
when I try to make a request without oauth_callback I get a valid response from the api
https://api.twitter.com/oauth/request_token?oauth_consumer_key=nHb2kSQ2CD9MW1MdW5VeQ&oauth_nonce=1356902849&oauth_signature=MbvhwGiNPKQR0klUPx9fsmUtdJY%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1356902849&oauth_version=1.0
when I add the oauth_callback string (mandatory to let users sign with a redirect!) I get "Failed to validate oauth signature and token"
https://api.twitter.com/oauth/request_token?oauth_callback=http%3A%2F%2F127.0.0.1%2Ftest%2F&oauth_consumer_key=nHb2kSQ2CD9MW1MdW5VeQ&oauth_nonce=1356902915&oauth_signature=2WTaI9jXNBaDd7f8AqIe6y3%2Beno%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1356902915&oauth_version=1.0
I mean there's no difference between the two URLs, they both go through the same execution and they respect the signing method.
How to fix it?
yes I added http://127.0.0.1/test/ as callback url in the twitter app settings.
Thank you
Have you set up the callback url in the twitter application settings?
If you don't set that up, the api may fail.
Check it from here:
Also check that your time is in sync (use an NTP server); see: https://dev.twitter.com/discussions/1043
Agreed that twitter API is badly documented :)
Follow this rule:
If your oauth_callback does not contain any query string = Nothing funky is required.
If your oauth_callback has any query string parameters = URL Encode the query string parameters separately.
Hope this explains.
I solved the issue. The problem was that even though the callback URL was sent correctly using the querystring method or headers as you can see on the links, it was also double escaped when creating the signature from the basestring. Since the documentation is pretty bad regarding this I didn't think that you shouldn't double escape it as well like other oauth_* parameters (aka percentage encode the "&"s).

while authenticating with foursquare, it returns 'invalid_request'

It is clear to me that this error is because of the wrong redirect_uri I have used. But what should I use for redirect_uri ? I just created an application in FourSquare, and I got the consumer token and consumer secret. I filled in a URL in the callback URL field. Now when I pick up this URL and set it as my redirect_uri, it is still invalid.
Can tell me how exactly should this be used? I found out that with OAuth2.0, you need to register the redirect_uri for safety of the user. Now how do I do that registration?
Your callback URL is the "redirect_uri". Make sure you've URI-encoded the parameter and that you haven't changed the url scheme by mistake (http vs https)

Resources