Question

Build auth using 'Bearer Token' authorization

  • 15 June 2023
  • 15 replies
  • 1666 views

Userlevel 1
Badge

Hi,

I’m trying to create a connection to Galaxy Digital’s getconnected platform. I’m told they also use a ‘Bearer Token’ API key, which I have.

I started with an API Key authentication with the following required fields, and even added the Header option suggested in another answer - did I get that right?

 

 

When I ran this and entered my 3 fields for authentication, I get the 401 error at bottom.

Did I simply login invalid? Or is something wrong with my authentication?

Thanks!

John


We hit an error adding your new account
authentication failed: The app returned "Unauthenticated.". What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {"status":401,"headers":{"content-type":"application/json","retry-after":null},"content":"{\"message\":\"Unauthenticated.\"}","request":{"url":"https://ca.volunteerapi.com/api/users?Authorization=Bearer%20%5BTOKEN%5D&password= ****************** &api_key=f28ef87c-**********************&email=john%40johnkirkwood.ca"}} at _throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:13:11) at Object.outResp.throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:68:5) at throwForStatusMiddleware (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-status.js:5:14) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:77:26 at Array.reduce (<anonymous>) at afterMiddleware (/var/task/node_modules/zapier-platform-core/src/middleware.js:76:21) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:94:18) From previous event: at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:92:10) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:89:45 at /var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:212:18 at bound (node:domain:433:15) at runBound (node:domain:444:12) at processImmediate (node:internal/timers:466:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:128:24) From previous event: at Domain.<anonymous> (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:196:10) at Domain.run (node:domain:389:15) at Runtime.handler (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:192:19) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1086:29)

Make sure you click "Allow" or "Accept" on the permission popup
Double check your Account has the correct permissions
Check out our help docs for more information


15 replies

Userlevel 1
Badge

Just got a reply from Galaxy, but it’s Greek to me:

“From your screenshot [of Zapier authentication options] and my knowledge of our API, I would recommend looking at Session Auth, because our API login endpoint generates a token after you enter your credentials in the /login endpoint. 

Here are some resources that will help you get started:

A sample CURL request so you can have a template of what a login request looks like with our API

curl --location 'https://api.galaxydigital.com/api/users/login' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data-raw '{   "user_email": "{{your email address}},   "user_password": "{{your password}}",   "key": "{{your api key}}" }'

When you call this endpoint, it will give you a token that you can use to authenticate calls to all other API endpoints. Based on the description in Zapier, Session Auth sounds like the right choice!”

Please help!

Thx :)

Userlevel 3
Badge +6

Hi @jkirkwood001 ,

Thanks for sharing those super helpful details!

Taking a look, one that stands out to me is that the endpoint/url in your screenshot is a bit different than the one shared by Galaxy Digital in their example code. 

Galaxy Digital’s code seems to refer to these docs:

http://api.galaxydigital.com/docs/#/Login/login

They appear to be using the following endpoint to authenticate:

https://api.galaxydigital.com/api/users/login

It’s also worth noting that their parameters are a bit different than those in your screenshot: user_email, user_password, and key

Based on those docs, I agree that Session authentication sounds like a good fit. 

If you haven’t already done so, it might help to check out the following resource, which walks through how Session auth works and how to set it up:

Overall, I might suggest trying this:

  1. Switch your integration’s Authentication to Session
  2. Create Authentication Fields to capture user_email, user_password, and key
  3. Plug https://api.galaxydigital.com/api/users/login as the Token Exchange Endpoint 
  4. Click Show Options to make sure the Authentication Fields are included in the request body

Hope this points you in the right direction!

Userlevel 1
Badge

 

Thanks @connorz !

Still getting authentication errors. I think I’m by the authentication, but the GET failed.

Here’s what I entered:

(I treied both login strings)

And here’s the error (odd, because I also tried GET for both places besides a PUT for the token request) 

We hit an error adding your new account

authentication failed: The app returned "405". What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {"status":405,"headers":{"content-type":"text/html; charset=iso-8859-1","retry-after":null},"content":"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>405 Method Not Allowed</title>\n</head><body>\n<h1>Method Not Allowed</h1>\n<p>The requested method PUT is not allowed for this URL.</p>\n</body></html>\n","request":{"url":"http://api.galaxydigital.com/docs/#/Login/login?Authorization=Bearer%20%5BTOKEN%5D"}} at _throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:13:11) at Object.outResp.throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:68:5) at throwForStatusMiddleware (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-status.js:5:14) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:77:26 at Array.reduce (<anonymous>) at afterMiddleware (/var/task/node_modules/zapier-platform-core/src/middleware.js:76:21) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:94:18) From previous event: at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:92:10) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:89:45 at /var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:212:18 at bound (node:domain:433:15) at runBound (node:domain:444:12) at processImmediate (node:internal/timers:466:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:128:24) From previous event: at Domain.<anonymous> (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:196:10) at Domain.run (node:domain:389:15) at Runtime.handler (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:192:19) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1086:29)

 

 

Userlevel 3
Badge +6

Hi @jkirkwood001 ,

Thanks for giving that a shot!

Comparing the screenshots to the docs…

http://api.galaxydigital.com/docs

...I have a few suggestions that I hope will help.

In the setting pictured below, let’s try making the following changes:

 

In the settings below, let’s:

  • Switch username TO user_email
  • Switch userpassword TO user_password
  • Add another field with the combo: key / {{bundle.authData.api_key}}

 

And let’s remove Authorization from the URL params:

 

Below, in the test request config, let’s:

  • Replace the URL with the following: https://api.galaxydigital.com/api/users
  • Remove the current URL Params and HTTP headers
  • Click the HTTP Headers tab and add the combo: Authorization / Bearer {{bundle.authData.token}}

 

Then let’s try testing the auth again. 

If that does not help, please feel free to reach out to our team and we’ll be glad to take a closer look at the integration: https://developer.zapier.com/contact

Userlevel 1
Badge

@connorz thanks so much for really trying to help.

Okay I did everything you listed exactly and still got an error.

Not sure if I entered this right? There was an error when I typed exactly what you had which was “Authorization / Bearer” so I separated them:

authentication failed: Authorization / Bearer is not a legal HTTP header name What happened (You are seeing this because you are an admin): Starting GET request to https://api.galaxydigital.com/api/users Authorization / Bearer is not a legal HTTP header name Console logs: Stack trace: TypeError: Authorization / Bearer is not a legal HTTP header name at validateName (/var/task/node_modules/node-fetch/lib/index.js:677:9) at Headers.append (/var/task/node_modules/node-fetch/lib/index.js:835:3) at new Headers (/var/task/node_modules/node-fetch/lib/index.js:761:11) at new Request (/var/task/node_modules/node-fetch/lib/index.js:1231:19) at new PatchedRequest (/var/task/node_modules/zapier-platform-core/src/tools/fetch.js:22:5) at newFetch (/var/task/node_modules/zapier-platform-core/src/tools/fetch.js:54:19) at request (/var/task/node_modules/zapier-platform-core/src/tools/request-client.js:26:10) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:90:22) at bound (node:domain:433:15) at Object.runBound (node:domain:444:12) at Object.tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:466:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:128:24)

 

Not sure how to ‘share’ this without publishing, but here’s the URL:

https://developer.zapier.com/app/185381/version/1.0.0/authentication/edit#2

Userlevel 1
Badge

...and it keeps saying “This account is expired.” so I’m re-entering my credentials each time. Why does it think I’m ‘Anonymous’?

 

 

authentication failed: What happened (You are seeing this because you are an admin): Starting GET request to https://api.galaxydigital.com/api/users Received 401 code from https://api.galaxydigital.com/api/users after 56ms Received content "{"message":"Unauthenticated."}" Console logs: Stack trace: RefreshAuthError at throwForStaleAuth (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-stale-auth.js:10:11) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) at bound (node:domain:433:15) at Object.runBound (node:domain:444:12) at Object.tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:466:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:128:24)

Userlevel 3
Badge +6

Hey @jkirkwood001 ,

Thanks for giving that a try! I think we’re getting close. 

In the test request’s headers, can you please try passing the following?

  • One header where the key is “Authorization” and the value is “Bearer {{bundle.authData.token}}”

 

To be transparent, I’m not entirely clear on how exactly they expect this header to be formatted, but the above is a pretty standard convention.

Userlevel 1
Badge

Changed these Labels to be in sync:

 

Now I get this different (progressing?) error - it’s still suggests I’m logging in as ‘Anonymous’ 🤷🏻:

 

authentication failed: The app returned "The given data was invalid.". What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {"status":422,"headers":{"content-type":"application/json","retry-after":null},"content":"{\"message\":\"The given data was invalid.\",\"errors\":{\"key\":[\"The key field is required.\"]}}","request":{"url":"https://api.galaxydigital.com/api/users/login"}} at _throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:13:11) at Object.outResp.throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:68:5) at throwForStatusMiddleware (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-status.js:5:14) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:77:26 at Array.reduce (<anonymous>) at afterMiddleware (/var/task/node_modules/zapier-platform-core/src/middleware.js:76:21) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:94:18) From previous event: at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:92:10) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:89:45 at /var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:212:18 at bound (node:domain:433:15) at runBound (node:domain:444:12) at processImmediate (node:internal/timers:466:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:128:24) From previous event: at Domain.<anonymous> (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:196:10) at Domain.run (node:domain:389:15) at Runtime.handler (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:192:19) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1086:29)

 

Userlevel 1
Badge

… I’ve also got a dozen ‘Connections’ in my Zapier profile, presumably all failed version of the one I’m editing..? Should I delete them all before trying again? Guess it couldn’t hurt...

 

 

Userlevel 3
Badge +6

Hi @jkirkwood001 ,

Yes, feel free to delete those failed connections. 

Regarding the error, it appears that Galaxy Digital’s API expects the API key property to be named key.

 

Can you please try renaming that property in the token exchange request to key (instead of api_key)?

 

Userlevel 1
Badge

Hi @connorz ,

Thanks again. Tried that and it also didn’t work:

Produced:

 

I should have included earlier, but here is the last email they sent me (I don’t know what a ‘CURL request’ is) - does this help?

 

Userlevel 3
Badge +6

Hi @jkirkwood001 , 

I see that the key of the API key field was changed, so it looks like the API key was left out of the request. 

In the token exchange request, on the right, can you please change {{bundle.authData.api_key}} to {{bundle.authData.key}}?

 

That should make sure the API key entered in the “API key” field gets passed as the key property in the request.

For a bit of context, cURL is another way you could make an HTTP request, like Zapier is doing. However, cURL is a command-line tool that you’d typically use locally on your computer. API documentation often uses cURL as a shorthand example. For our purposes, the cURL example is helpful because it shows the URL and properties we need to use in the request, but Zapier can’t run cURL directly. So we’re essentially translating the cURL example into the format Zapier uses.

Userlevel 1
Badge

Hi @connorz ,

I retried this again after validating my API and changing the field names as you described, and I’m still getting an error:

Any further suggestions?

Thanks,

J

Userlevel 3
Badge +6

Hey @jkirkwood001 ,

From the error, it looks like the endpoint might have changed. 

I recall Galaxy Digital shared the following endpoint url:

https://api.galaxydigital.com/api/users/login

Is that, instead of the volunteerapi.com… endpoint also hitting an error?

Userlevel 1
Badge

To @connorz and others, thank you!

Just to close the loop on this, with Galaxy Support we finally got authentication to work using API Key authentication (see below).

Now I’m working on part 2, the trigger. Not solved yet, but I hope the hardest part is behind me!

 

Reply