0

I'm trying to authenticate to the MAAS REST API through PHP but I'm not having any luck finding the best way to do so. Basing on the (outdated) examples here: https://maas.io/docs/snap/3.0/ui/api-authentication for ruby and python you need to send the 3 parts of the key but all examples using PHP OAuth1 have only 2 parts of the key so I'm wondering if there is anything about that would allow me to use PHP with MAAS.

TIA

Pete Wall
  • 55
  • 11
  • Which parts of the key are you referring to? According to this, https://github.com/CanonicalLtd/maas-docs/issues/647#issuecomment-379478724, you can use a blank space for _Consumer Secret_. – waterloomatt Sep 09 '21 at 12:01
  • Going off of [this link](https://stackoverflow.com/questions/44591780/oauth-1-0-connection-to-an-api) I can't see where I would add the third part of the key or (in that example) what the callback would be – Pete Wall Sep 09 '21 at 12:28
  • I've gotten a bit further with this issue but I'm now getting `Exception caught! Response: Authorization Error: 'Invalid signature. Expected signature base string: &CtCtyvpdn4gdNHw4g8y8VJsJEKXrrXTb` – Pete Wall Sep 14 '21 at 09:07
  • Using this code: `setToken("TOKEN","TOKEN-SECRET"); $oauth->fetch("http://10.16.97.10:5240/MAAS/api/2.0/account/?op=list_authorisation_tokens"); $response_info = $oauth->getLastResponseInfo(); header("Content-Type: {$response_info["content_type"]}"); echo $oauth->getLastResponse(); } catch(OAuthException $E) { echo "Exception caught!\n"; echo "Response: ". $E->lastResponse . "\n"; } ?>` Any ideas? – Pete Wall Sep 14 '21 at 09:09
  • Got this working with https://github.com/guzzle/oauth-subscriber instead, working perfectly now – Pete Wall Sep 14 '21 at 10:33

0 Answers0