Viincenttt / MollieApi

This project allows you to easily add the Mollie payment provider to your application.
MIT License
150 stars 85 forks source link

C# SDK does not allow me to fetch profile with Oauth access token #281

Closed SDanDyS closed 1 year ago

SDanDyS commented 1 year ago

I am implementing Oauth2 and wish to retrieve a profileId, which should be used for payments. However when trying to use Oauth to retrieve a profileId I get the following error "MollieApiException: Forbidden - This API endpoint is only available with an API key and cannot be accessed with an OAuth access token.". In the PHP SDK it's possible to retrieve profiles (including the current profile) through Oauth. Is this also possible within the C# SDK, or hasn't this been implemented yet? The implementation of the retrieval of the profileId is done like this:

IProfileClient client = new ProfileClient(this.tokenResponse.AccessToken);
ProfileResponse profileResponse = await client.GetCurrentProfileAsync();
this.profileResponse = profileResponse;

am I missing something?

Viincenttt commented 1 year ago

Hmmm.... I'm not sure. Looking at the exception it does seem to come from the Mollie API. I'll have to do some investigating on this. I'll come back on this.

Viincenttt commented 1 year ago

Looking at the API documentation, the endpoint you are calling ("Get current profile") does not support OAuth tokens: https://docs.mollie.com/reference/v2/profiles-api/get-profile-me

image

The "Get profile" endpoint does support this: https://docs.mollie.com/reference/v2/profiles-api/get-profile

I'm not familiar with the PHP client library.

SDanDyS commented 1 year ago

Well, if only the API key works for a profile, then I doubt the PHP library did this as well. I must've been thinking of something else. But to be sure (debugger already somewhat confirmed this): I can pass an access token to the PaymentClient object and it'll internally handle it, correct?

Viincenttt commented 1 year ago

Jep, that should totally work :)

I'm closing this issue for now. Feel free to reply or open a new issue if you encounter any problems :)