How to pass API key in VBA for Get and Post Request?

后端 未结 2 1173
挽巷
挽巷 2021-01-16 23:39

I am using https://developer.companieshouse.gov.uk/api/docs/ to access an API I have my API key, however, i am not sure how to pass that from VBA. So far i tried below

2条回答
  •  深忆病人
    2021-01-17 00:24

    Basic auth requires the username and password to be base 64 encoded together. The AuthKey you need to pass is essentially:

    def unencoded_auth = "[username]:[authkey]"
    def encoded_auth = *call-to-base64-encode-value*(unencoded_auth)
    

    Then you would replace

    "Basic " & AuthKey
    

    with

    "Basic " & encoded_auth
    

    I'll reference this post as to how to achieve the base64 encoding.

提交回复
热议问题