首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >groovy在pin支付中的秘密密钥位置

groovy在pin支付中的秘密密钥位置
EN

Stack Overflow用户
提问于 2014-05-12 04:31:30
回答 2查看 230关注 0票数 0

我正在做pin.net.au中的pin支付api,我遇到了一些错误,如您在下面看到的

代码语言:javascript
复制
`@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder'`,` version='0.5.0-RC2' )
    import groovyx.net.http.*
    import groovyx.net.http.HttpResponseDecorator
    import groovyx.net.http.RESTClient
    import static groovyx.net.http.ContentType.*
    import groovyx.net.http.HttpResponseException
    import groovy.swing.SwingBuilder
    import javax.swing.JFrame
    import wslite.http.auth.*
    class Customers {

        Customers(){
            def rst = new RESTClient( 'https://test-api.pin.net.au/1/')
    rst.auth.basic 'mySecretKey',''
            def res = rst.post( path: 'customers'){
                type ContentType.XML
                xml {
                    cards{
                        email('pk_qTj9Umqmlf3o7lfa6F9nWw')
                        card[expiry_month]('12')
                        card[expiry_year]('2015')
                        card[cvc]('123')
                        card[name]('patrick pl')
                        card[address_line1]('23 frfds')
                        card[address_city]('Angeles')
                        card[address_postcode]('2009')
                        card[address_state]('ph')
                        card[address_country]('Philippines')

                    }
                }

            }

        }
        public static void main(String []args){

            new Customers()
        }
    }

当我运行代码时,错误是

代码语言:javascript
复制
   May 12, 2014 1:07:35 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
    WARNING: Authentication error: Unable to respond to any of these challenges: {}
    Caught: groovyx.net.http.HttpResponseException: Authorization Required
    groovyx.net.http.HttpResponseException: Authorization Required
        at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:240)
        at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:475)
        at groovyx.net.http.HTTPBuilder.post(HTTPBuilder.java:335)
        at groovyx.net.http.HTTPBuilder$post.call(Unknown Source)
        at PinPayment.Customers.<init>(Customers.groovy:16)
        at PinPayment.Customers.main(Customers.groovy:39)

如何使身份验证使代码可运行??以下是docs pin.net.au的链接

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-19 02:12:12

我在这里找到了适合特定api的代码,def http = new RESTClient('https://test-api.pin.net.au/1/') http.headers['Authorization'] = 'Basic '+"tWqZl0MHsg5nUQdB6czrDQ:".getBytes('iso-8859-1').encodeBase64()

票数 0
EN

Stack Overflow用户

发布于 2014-05-12 04:45:23

文档表明它需要基本的HTTP。

对Pin Payments API的调用必须使用HTTP身份验证进行身份验证,其用户名为API密钥,密码为空白字符串。

因此:

代码语言:javascript
复制
def rst = new RESTClient( 'https://test-api.pin.net.au/1/' )
rst.auth.basic 'secretAPIKeyHereAsString', ''
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23601077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档