Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7792453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:11:19+00:00 2026-06-01T22:11:19+00:00

Is there any library in Ruby that generates the Signature, ‘X-PAYPAL-AUTHORIZATION’ header that is

  • 0

Is there any library in Ruby that generates the Signature, 'X-PAYPAL-AUTHORIZATION' header that is required to make calls on behalf of the account holder who has authorized us through the paypal Permissions API.
I am done with the permissions flow and get the required access token, tokenSecret. I feel I am generating the signature incorrectly as all my calls with the the generated ‘X-PAYPAL-AUTHORIZATION’ fail. They give the following errors:

For NVP call I get:
You do not have permissions to make this API call

And for the GetBasicPersonalData call I get:
Authentication failed. API credentials are incorrect.

Has anyone gone through this in Ruby? What is best way to generate signature. Paypal has just provided some SDK in Paypal, Java, but not the algorithm to generate signature.

Thanks,
Nilesh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:11:21+00:00Added an answer on June 1, 2026 at 10:11 pm

    Take a look at the PayPal Permissions gem.

    https://github.com/moshbit/paypal_permissions

    Specifically lib/paypal_permissions/x_pp_authorization.rb
    require ‘cgi’
    require ‘openssl’
    require ‘base64’

    class Hash
      def to_paypal_permissions_query
        collect do |key, value|
          "#{key}=#{value}"
        end.sort * '&'
      end
    end
    
    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
        module XPPAuthorization
          public
          def x_pp_authorization_header url, api_user_id, api_password, access_token, access_token_verifier
            timestamp = Time.now.to_i.to_s
            signature = x_pp_authorization_signature url, api_user_id, api_password, timestamp, access_token, access_token_verifier
            { 'X-PAYPAL-AUTHORIZATION' => "token=#{access_token},signature=#{signature},timestamp=#{timestamp}" }
          end
    
          public
          def x_pp_authorization_signature url, api_user_id, api_password, timestamp, access_token, access_token_verifier
            # no query params, but if there were, this is where they'd go
            query_params = {}
            key = [
              paypal_encode(api_password),
              paypal_encode(access_token_verifier),
            ].join("&")
    
            params = query_params.dup.merge({
              "oauth_consumer_key" => api_user_id,
              "oauth_version" => "1.0",
              "oauth_signature_method" => "HMAC-SHA1",
              "oauth_token" => access_token,
              "oauth_timestamp" => timestamp,
            })
            sorted_query_string = params.to_paypal_permissions_query
    
            base = [
              "POST",
              paypal_encode(url),
              paypal_encode(sorted_query_string)
            ].join("&")
            base = base.gsub /%([0-9A-F])([0-9A-F])/ do
              "%#{$1.downcase}#{$2.downcase}"  # hack to match PayPal Java SDK bit for bit
            end
    
            digest = OpenSSL::HMAC.digest('sha1', key, base)
            Base64.encode64(digest).chomp
          end
    
          # The PayPalURLEncoder java class percent encodes everything other than 'a-zA-Z0-9 _'.
          # Then it converts ' ' to '+'.
          # Ruby's CGI.encode takes care of the ' ' and '*' to satisfy PayPal
          # (but beware, URI.encode percent encodes spaces, and does nothing with '*').
          # Finally, CGI.encode does not encode '.-', which we need to do here.
          def paypal_encode str
            s = str.dup
            CGI.escape(s).gsub('.', '%2E').gsub('-', '%2D')
          end
        end
      end
    end
    

    Sample parameters:

    url = 'https://svcs.sandbox.paypal.com/Permissions/GetBasicPersonalData'
    api_user_id = 'caller_1234567890_biz_api1.yourdomain.com'
    api_password = '1234567890'
    access_token = 'YJGjMOmTUqVPlKOd1234567890-jdQV3eWCOLuCQOyDK1234567890'
    access_token_verifier = 'PgUjnwsMhuuUuZlPU1234567890'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any Ruby library that supports HTTP Digest?
Is there any library that allows to handle google talk messages using Ruby?
Is there any library that can produce server-side pie charts using Ruby? Such as
Is there any library that allows to handle Skype messages using Ruby?
Is there any PHP or Ruby library to convert Tranditional Chinese to Simplified Chinese
Is there any Library for .NET that returns SPARQL results in some structured List
Is there any library out there that I can use to create epub files
is there any javascript library that provides me with a custom event as soon
Is there any c# library that handles lossless conversion between different image formats?
Are there any Ruby gems/libraries that help you migrate from an old DB structure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.