Connecting to Microsoft Dynamics 365 CRM

Hi everyone,

I’m trying to connect to Microsoft Dynamics 365 CRM via bubble’s API connector. I’ve successfully created an API to sign in with Microsoft. However, when using the same OAuth2 authentication I keep getting a 401 unauthorized error. I’ve been combing through the forms here and on Microsofts API documentation but I can’t figure it out.

Any suggestions would be much appreciated.

Thanks!

@Jici Any chance you would know how to approach this?

Do you mean you initially tested the API using signin with social network in run mode and now you are trying to initialize API Call endpoint?
The warning say that it’ not tested (or expired). Bubble API Connector doesn’t keep your signin alive. You need to reauthenticate in runmode to be able to initialize call.
Also, not sure you have the correct endpoint to get user DATA. Better to have en email key path instead of name.

Yes, I got those settings in the screen shot to work with User Profile endpoint of “https://graph.microsoft.com/v1.0/me” to log the user in and get their information.

However when I swap the endpoint to the dynamics URL (in screenshot above) and try to run the login workflow or when trying to initialize a GET for the dynamics URL I get an error:
api error

I’m trying to get the user’s data from Dynamics CRM to display it on a bubble io dashboard when they log in.

You should keep first the /me endpoint for Bubble and use an API Call to reach the dynamic endpoint

Actually, your screenshot show that the API Connector is not authenticated

I can authenticate with the /me endpoint but when trying to call the dynamic endpoint I get this fun guy:
image
Even though my credentials are authorized for the dyanmics end point, I’m able to put the dynamics endpoint URL in my browser and see all the OData feed. However, I can’t call it from bubble.

Also thank you for your help with this!

Did you check requested scopes?

I’ve tried a handful but no luck.

https://x.api.crm.dynamics.com/user_impersonation offline_access
user.read
openid offline_access

but still getting rejected with 401 error.

Do you think it’s something with the access token?

access token probably not because this is from authorize process, but configuration of the APP in MS or with the scopes yes.
Can you share the whole settings in API Connector including API Call?

I don’t have enough time available to read MS dynmics auth documentation. There’s a lot of possible thing to consider like if you are using AD, on-premise… That may affect authentication process.

I will keep digging, I appreciate your help narrowing it down. Thank you very much!

So I got it to work in Postman, but I’m having trouble transferring it over to bubble now. All I did in postman was setup the Oauth2 then ran the GET request on the dynamics URL and it worked.

However, I am not sure how to transfer over Postman settings to Bubble API as I’m not great with APIs.

Any chance you would be able to help translate? Again, I appreciate your help with this very much.

You seem to use an implicit grant type that is different from authorization code flow. You could try maybe to use token is returned as querystring (that is what implicit do while a code is returned in authorization code and you exchange this code for an access token. implicit will directly return implicit grant)

I couldn’t get it to work using the return as query string so I switched from implicit to Authorization Code in Postman and got it to work as well.


However, I’m still unsure on how to get it working in Bubble with the new Postman settings using Authorization Code.

You should paste the same auth url, access token url, scopes and keys. user the /me endpoint and initialize theAPI. Once it’s done, add the same call to dynamics in API call and try to initialize.