/// <summary> /// Invokes the GetAccessToken API that requests third party permissions /// from another PayPal user for the API caller /// </summary> /// <param name="context"></param> private void RequestPermissions(HttpContext context) { // Restrict permissioning scope to "INVOICING" // This will allow the API caller to invoke any invoicing related API // on behalf of the permission granter String requestperm = "INVOICING"; PayPal.Permissions.Model.RequestPermissionsRequest rp = new PayPal.Permissions.Model.RequestPermissionsRequest(); rp.scope = new List <string>(); rp.scope.Add(requestperm); string url = context.Request.Url.Scheme + "://" + context.Request.Url.Host + ":" + context.Request.Url.Port; string returnURL = url + "/GetAccessToken.aspx?source=" + context.Request.UrlReferrer.LocalPath; rp.callback = returnURL; PayPal.Permissions.Model.RequestPermissionsResponse rpr = null; try { PayPal.Permissions.PermissionsService service = new PayPal.Permissions.PermissionsService(); rpr = service.RequestPermissions(rp); string ret = "<div class='overview'>Step 1) Invoke the RequestPermissions API and redirect third party to " + "PayPal so that the user may login and grant permissions to the API caller<br/></div>"; ret = ret + "<a href="; ret = ret + ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + "_grant-permission&request_token=" + rpr.token; ret = ret + "> Redirect URL (Click to redirect) </a><br/><br/>"; context.Response.Write(ret); context.Response.Write("<html><body><textarea rows=30 cols=80>"); ObjectDumper.Write(rpr, 5, context.Response.Output); context.Response.Write("</textarea></body></html>"); } catch (System.Exception e) { context.Response.Write(e.Message); return; } }
/// <summary> /// Invokes the GetAccessToken API that requests third party permissions /// from another PayPal user for the API caller /// </summary> /// <param name="context"></param> private void RequestPermissions(HttpContext context) { // Restrict permissioning scope to "INVOICING" // This will allow the API caller to invoke any invoicing related API // on behalf of the permission granter String requestperm = "INVOICING"; PayPal.Permissions.Model.RequestPermissionsRequest rp = new PayPal.Permissions.Model.RequestPermissionsRequest(); rp.scope = new List<string>(); rp.scope.Add(requestperm); string url = context.Request.Url.Scheme + "://" + context.Request.Url.Host + ":" + context.Request.Url.Port; string returnURL = url + "/GetAccessToken.aspx?source=" + context.Request.UrlReferrer.LocalPath; rp.callback = returnURL; PayPal.Permissions.Model.RequestPermissionsResponse rpr = null; try { PayPal.Permissions.PermissionsService service = new PayPal.Permissions.PermissionsService(); rpr = service.RequestPermissions(rp); string ret = "<div class='overview'>Step 1) Invoke the RequestPermissions API and redirect third party to " + "PayPal so that the user may login and grant permissions to the API caller<br/></div>"; ret = ret + "<a href="; ret = ret + ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"] + "_grant-permission&request_token=" + rpr.token; ret = ret + "> Redirect URL (Click to redirect) </a><br/><br/>"; context.Response.Write(ret); context.Response.Write("<html><body><textarea rows=30 cols=80>"); ObjectDumper.Write(rpr, 5, context.Response.Output); context.Response.Write("</textarea></body></html>"); } catch (System.Exception e) { context.Response.Write(e.Message); return; } }