I try to post several scope values to allow my application for some google service...
I tried with two input field
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.email" />
and with one input field with + separator
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar+https://www.googleapis.com/auth/userinfo.email" />
When I send my form with only one scope It work.
otherwise with sereval scope value google redirect me with this error description :
http://localhost:49972/redirect.aspx#error=invalid_request&error_description=OAuth+2+parameters+can+only+have+a+single+value:+scope&error_uri=http://code.google.com/apis/accounts/docs/OAuth2.html
In the google getting started with oAuth2 it works with two scope values.
Here is my code :
<form id="form1" method="post" action="https://accounts.google.com/o/oauth2/auth?" >
<div>
<input type="hidden" name="response_type" value="code" />
<input type="hidden" name="client_id" value="my client id" />
<input type="hidden" name="redirect_uri" value="http://localhost:49972/redirect.aspx" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.email" />
<input type="hidden" name="state" value="/profile" />
<input type="submit" value="go" />
</div>
</form>
You were on the right track when you combined them to a single field
. There should be only one scope parameter in the request, with the values separated by spaces. If you're putting it in a form like that, the browser will take care of encoding the space for you.
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email" />
In addition to Steve Bazyl's answer. When applying multiple scopes for the same Google service, order of scopes seems to matter. F.e this string works as expected:
"https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.metadata.readonly"
while this one does not work for me:
"https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/drive"
I have not found any information about that in the docs though.
You can put all scopes in 1 array for clarity:
const scopes = [
'openid',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/gmail.readonly',
]
const scope = scopes.join(' ')
console.log(scope)
// openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/gmail.readonly
const redirectUri = 'http://localhost:3000'
const link = `https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=${scope}&response_type=code&client_id=${GOOGLE.clientId}&redirect_uri=${redirectUri}&state=authGoogle`
Related
I have the following HTML which works well for subscription payments in my test environment.
<form action="paypalWebAddress" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick-subscriptions"/>
<input type="hidden" name="business" value="myPaypalAccountId"/>
<input type="hidden" name="paymentaction" value="sale"/>
<input type="hidden" name="item_name" value="Subscription For abc123"/>
<input type="hidden" name="currency_code" value="GBP"/>
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="a3" value="50"/>
<input type="hidden" name="p3" value="6"/>
<input type="hidden" name="t3" value="M"/>
<input type="hidden" name="src" value="1" />
<input type="hidden" name="srt" value="0" /><!--needs to be never ending-->
<input type="hidden" name="return" value="www."/>
<input type="hidden" name="notify_url" value="www."/>
<input type="hidden" name="cancel_url" value="www."/>
<input type="hidden" name="custom" value="abc123"/>
<input TYPE="hidden" name="charset" value="utf-8">
<input type="hidden" name="bn" value="Me_Subscribe_WPS_UK" />
<input type="submit" name="submit" value="Make Payment"/>
</form>
I'm about to go live and concerned that some one could easily manipulate the DOM and I'm suddenly sending bogus payments. I feel it would be safer to somehow post these values from the code behind so the user can't tamper with the values but, the user will still need to use the PayPal interface in their browser to log in and subscribe.
PayPal-NET-SDK has a quick start and shows how to get going. I have completed this (copied and pasted and ran in debug mode) and it executes fine. However, this doesn't cover subscriptions, probably for the reason explained above (and would probably prevent them accessing the PayPal gui in their browser).
I get the option in the PayPal dashboard area to create a button and reference by button, but, this won't work for me as I need to be able to set the custom field per subscription as a user can subscribe to 1 or more services and each service is unique to that user.
I can't understand how to achieve this
If I understand this right, every subscription is unique per customer in your case and that won't work with the static buttons, so the API seems the only way to go.
The PayPal API does cover subscriptions, they're called Billing Plans. Because each subscription is different, you could create a new Billing Plan for each unique service (or combination of services). This can be done without any intermediate SDK using the HttpClient directly to their API.
Alternatively, the PayPal-NET-SDK you mentioned also seems to cover Billing plans. Their Sample application has quite a lot of examples on how to create, enumerate and issue Billing Plans. Make sure you check out the billing_agreement_tokens collection on the Payment class. You might add multiple "service" tokens there.
No matter how close you are to releasing, a lot of testing still seems to be in order here.
You can try using HttpClient, something like this will help
HttpContent content = new FormUrlEncodedContent(
new List<KeyValuePair<string, string>> {
new KeyValuePair<string, string>("key1",
"value1"),
new KeyValuePair<string,string>("key2","value2")
});
content.Headers.ContentType = new
MediaTypeHeaderValue("application/x-www-form-
urlencoded");
content.Headers.ContentType.CharSet = "UTF-8";
HttpResponseMessage resposne = await
client.PostAsync(new Uri("paypalWebAddress"),
content);
You should not hardcode the values in forms, instead you should create an API in the backend which will return the correspoding values.Then you can dynamically create the form based on the response of the API.
Make sure you create this form after you have received the response from the API.You can have a check like if response is null show some spinner.
<form action="paypalWebAddress" method="post" target="_top">
<input type="hidden" name="cmd" value="{response.cmd}"/>
<input type="hidden" name="business" value={response.business}"/>
<input type="hidden" name="paymentaction" value={response.action}/>
<input type="hidden" name="item_name" value="{response.item}"/>
<input type="submit" name="submit" value="Make Payment"/>
</form>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="business.test.com">
<input type="hidden" name="item_name" value="Memory Stick">
<input type="hidden" name="item_number" value="MEM32507725">
<input type="hidden" name="amount" value="3">
<input type="hidden" name="tax" value="1">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="currency_code" value="USD">
<!-- Enable override of buyers's address stored with PayPal . -->
<input type="hidden" name="address_override" value="1">
<!-- Set variables that override the address stored with PayPal. -->
<input type="hidden" name="first_name" value="John">
<input type="hidden" name="last_name" value="Doe">
<input type="hidden" name="address1" value="345 Lark Ave">
<input type="hidden" name="city" value="San Jose">
<input type="hidden" name="state" value="CA">
<input type="hidden" name="zip" value="95121">
<input type="hidden" name="country" value="US">
<input type="image" name="submit"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
</form>
On Click on buy now :
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="herschelgomez#xyzzyu.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Premium Umbrella">
<input type="hidden" name="amount" value="50.00">
<input type="hidden" name="currency_code" value="USD">
<!-- Prompt buyers to enter the quantities they want. -->
<input type="hidden" name="undefined_quantity" value="1">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="Buy Now">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
WHAT I AM TRYING TO DO
I am simply trying to display the results of a Paypal subscription signup. I see the issue of not being able to see the POST variables is a common issue.
I have tried many different ways to do this and I see a common solution is to use:
<input id="rm" name="rm" type="hidden" value="2">
This does not work.
I have tried emailing myself $_POST and $_REQUEST variables and they are empty.
However, my code that detects the txn_type $_POST variable works, since my variables appear in my database. After writing to the database, it is supposed to show a receipt, but does not.
Here's the button code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="paypalemail#gmail.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="Monthly Featured Listings">
<input type="hidden" name="item_number" value="1">
<!-- Set the terms of the regular subscription. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="0.01">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="rm" value="2">
<!-- Set recurring payments until canceled. -->
<input type="hidden" name="src" value="1">
<input name="notify_url" value="http://www.example.com/user/register/index.php" type="hidden">
<input name="return" value="http://www.example.com/user/register/index.php" type="hidden">
<input name="cancel_return" value="http://www.example.com/user/register/index.php?payment=cancelled" type="hidden">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="http://www.example.com/images/register-and-pay-now.png" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">
Since my database code works, I can only guess that Paypal is sending the information correctly, but I can't get it to show up in the web page.
My QUESTION
How can I show successful $_POST variables in my page after the redirect?
Well, my guess is that the variables that you are receiving and storing to the database are hitting the notify_url.
These variables are the IPN variables and are not supposed to be shown on any web page.
In order to get information on the specified return URL you have to access the PDT data.
Read more about PDT here
I want to make a program in C# which will go/login and do stuff on a website. I'm using Fiddler to see which URL should I use.
So, in Fiddler I write:
https://landfill.bugzilla.org/bugzilla-tip/post_bug.cgi?Bugzilla_login=mymail#hotmail.com&Bugzilla_password=mypassword&product=WorldControl&version=1.0&component=WeatherControl&rep_platform=All&op_sys=All&priority=P2&bug_severity=normal&target_milestone=World 202.0&bug_status=CONFIRMED&assigned_to=mymail#hotmail.com&short_desc=bla
And I send it with POST. I get a message which says: "Are you sure you want to commit these changes anyway? This may result in unexpected and undesired results."
Then, there is a button which says 'Confirm changes'. Its code in the result html page is:
<form name="check" id="check" method="post" action="post_bug.cgi">
<input type="hidden" name="product"
value="WorldControl">
<input type="hidden" name="version"
value="1.0">
<input type="hidden" name="component"
value="WeatherControl">
<input type="hidden" name="rep_platform"
value="All">
<input type="hidden" name="op_sys"
value="All">
<input type="hidden" name="priority"
value="P2">
<input type="hidden" name="bug_severity"
value="normal">
<input type="hidden" name="target_milestone"
value="World 2.0">
<input type="hidden" name="bug_status"
value="CONFIRMED">
<input type="hidden" name="assigned_to"
value="mymail#hotmail.com">
<input type="hidden" name="short_desc"
value="bla">
<input type="hidden" name="token"
value="aGipS2Hfim">
<input type="submit" id="confirm" value="Confirm Changes">
What should I write as URL in Fiddler or in browser to click this Confirm button?
You should submit POST data to URL https://landfill.bugzilla.org/bugzilla-tip/post_bug.cgi .
POST data should be as follows :
version=1.2&Component=WeatherControl& .... etc
Don't forget to encode POST data and set content type to "application/x-www-form-urlencoded"
UPDATE: When you receive first answer with confirm button, parse it as DOM and submit it again to same URL.This should behave same as you click on confirm button
The problem was that the parameters shouldn't be in the URL. This isn't GET method.
Can any one help me in passing the parameters to the worldpay site using mvc http post , below is the example which i found on google , the example is working on view , but I want to pass the parameters through http[post] action controller :
<form method="post" action="https://secure.wp3.rbsworldpay.com/wcc/purchase" id="frmWorldPay">
<input type="hidden" name="instId" value="1" />
<input type="hidden" name="cartId" value="<%: Model.CardID %>" />
<input type="hidden" name="currency" value="GBP" />
<input type="hidden" name="amount" value="<%= Model.Cost%> " />
<input type="hidden" name="desc" value="<%: ViewBag.Name %> track day" />
<input type="hidden" name="email" value="<%: Model.aspnet_Users.aspnet_Membership.Email %>" />
<input type="hidden" name="name" value="<%: Model.FullName %>" />
<input type="hidden" name="address" value="<%: Model.Address %>" />
<input type="hidden" name="testMode" value="100" />
Have a look at System.Net.WebClient.
Also this question on SO may help you further.
edit
You should follow the links I posted. There you find i.e. this example code
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;
//...
string url = "http://www.amazon.co.uk/exec/obidos/search-handle-form";
NameValueCollection formData = new NameValueCollection();
formData["field-keywords"] = "Harry Potter";
// add more form field / values here
WebClient webClient = new WebClient();
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string response = Encoding.UTF8.GetString(responseBytes);
Console.WriteLine(response);
I am using Razor to generate a form. I want to create HTML elements based on some value from it's model property.
for example, if a model contains Id property, and I want to generate html tags as follows
<input type="hidden" name="1_chk" />
<input type="hidden" name="2_chk" />
<input type="hidden" name="3_chk" />
So I used the following syntax, and it failed. Can anyone help me out with this?
<input type="checkbox" name="#Id_chk" />
Thanks
I think this should work for you:
<input type="checkbox" name="#(Id)_chk" />
another option:
<input type="checkbox" name="#(Id + "_chk")" />