Skip to content

Conversation

@AbrahamBrookes
Copy link
Contributor

When I was connecting my app using this library I hit an issue where the oauth credentials were throwing an error: Undefined array key "tenant_id" , because the structure from $oauth->getData() had my tenants as an array, as opposed to the single tenant_id expected:

dd( $oauth->getData() );

// results in 

[
  "token" => "asdasdasdasdasdasd"
  "refresh_token" => null
  "id_token" => "asdasdasdasdasdasdasdaasd"
  "expires" => 1657593567
  "tenants" => [
    0 => [
      "Id" => "asdasdasd-asdasd-asdasd-asdasd-asdasdasda"
      "Name" => "Demo Company (AU)"
    ]
  ]
]

I'm not sure if this is a permanent API change or if the response changes depending on your Xero account settings or what, but this change allows for my integration to proceed without breaking anything else, so I thought I might as well push it!

When I was connecting my app using this library I hit an issue where the oauth credentials were throwing an error: `Undefined array key "tenant_id"` , because the structure from `$oauth->getData()` had my tenants as an array, as opposed to the single tenant_id expected:

```
dd( $oauth->getData() );

// results in 

[
  "token" => "asdasdasdasdasdasd"
  "refresh_token" => null
  "id_token" => "asdasdasdasdasdasdasdaasd"
  "expires" => 1657593567
  "tenants" => [
    0 => [
      "Id" => "asdasdasd-asdasd-asdasd-asdasd-asdasdasda"
      "Name" => "Demo Company (AU)"
    ]
  ]
]
```

I'm not sure if this is a permanent API change or if the response changes depending on your Xero account settings or what, but this change allows for my integration to proceed without breaking anything else, so I thought I might as well push it!
@hailwood
Copy link
Contributor

Hi @AbrahamBrookes,

You're right this is definitely a bug, It was introduced in #71 by us not updating this so it is a permanent API change.

Rather than setting the ID from the first tenant, can you please remove the tenant_id property and add a tenants property that expects the array?

Cheers!

update the tenant_id property in XeroAuthorized for API change as per foxbytehq#74 (comment)
@AbrahamBrookes
Copy link
Contributor Author

cool thanks! that's been updated in 334b2c3 and tested working in my project:
image

@hailwood hailwood merged commit 5f2d104 into foxbytehq:master Jul 12, 2022
@hailwood
Copy link
Contributor

Thanks @AbrahamBrookes,

That's now been released

@AbrahamBrookes
Copy link
Contributor Author

Legend! Aw, my first PR package pull. This calls for a celebration 🥃

@hailwood
Copy link
Contributor

Congrats @AbrahamBrookes,

It's a good feeling!

hailwood pushed a commit that referenced this pull request Aug 12, 2024
* Handle multiple tenants in XeroAuthorized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants