MSBA-272 · Lesson 7 of 12 · 19 min
Authentication for connectors
▶ Video coming soon A video version of this lesson is on the way.
Every connector call carries an identity, and choosing which identity is the most consequential decision in connector design. It decides what the API lets the caller do, whose name appears in the API's logs, what happens when a person leaves the college, and how much damage a leaked credential could do. Lumenvale's three custom connectors used three different approaches, which made them a good set for teaching. Signe walked Wiremu through each one, starting with the one she now regretted least.
The authentication types
A custom connector's security settings offer a small set of authentication types. The connector stores the settings; each connection created from it holds the actual credentials or tokens for one user or service account.
| Type | How it works | Typical use |
|---|---|---|
| No authentication | Requests carry no credentials | Public APIs only |
| Basic authentication | A user name and password sent with each request | Older internal APIs; avoid for new work |
| API key | A key sent in a header or query parameter | Vendor APIs that issue keys; simple service-to-service calls |
| OAuth 2.0 | The connection signs in through an identity provider and receives access and refresh tokens | Modern APIs, including APIs protected by Microsoft Entra ID |
| Windows authentication | Windows credentials, used through an on-premises data gateway | Internal APIs on the college network |
OAuth 2.0 has several identity provider options, including a generic OAuth 2.0 setting for any compliant provider and dedicated settings for common providers. The most important for Lumenvale was Microsoft Entra ID, which the college used for every staff and student account.
Student Records: Microsoft Entra ID with delegated access
Signe had built the Student Records connector to let apps check whether a student had a hold. The student records system exposed a small REST API that Lumenvale's integration team had put behind Microsoft Entra ID. That made OAuth 2.0 with Entra ID the obvious choice, and it gave the strongest result: each maker or app user signed in as themselves, and the API saw who was calling.
Setting it up took two app registrations in Entra ID. The first represented the API and defined the permission it offered, a delegated scope for reading holds. The second represented the connector as a client: it had a client ID and secret, a redirect URI pointing at Power Platform's consent service, and permission to call the API's scope. The connector's security settings named the client ID and secret, the resource or scope to request, and the redirect URI.
"securityDefinitions": {
"oauth2-auth": {
"type": "oauth2",
"flow": "accessCode",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"tokenUrl": "https://login.windows.net/common/oauth2/authorize",
"scopes": {}
}
}Microsoft introduced a per-connector redirect URI for custom connectors, so each connector has its own redirect address rather than sharing one global address. Signe had updated the Student Records connector's client app registration when Microsoft asked customers to move, and she showed Wiremu where the setting lived so he would use it from the start.
The benefit of delegated access showed up in the API's own authorization. The student records system knew which staff could see which students, and it applied those rules to every call because it knew who was calling. An adviser at Ridgeview using the hold check saw only what the student records system allowed Ridgeview advisers to see. A connector that called the API with one shared account would have had to reproduce those rules, badly, in Power Platform.
Connections and who they act as
Wiremu understood the theory but not where connections lived in practice. Signe explained the two common cases. In a canvas app, each user who runs the app is asked to create their own connection to the connector the first time, so calls run as that user. In a cloud flow, the connections are those chosen when the flow was built or deployed: an automated flow runs with the connections of its owner or the connection references set during deployment, not with the identity of whoever triggered it, unless the flow is configured to run actions with the invoker's connection.
That difference explains a whole category of security mistakes. A flow that checks holds using its owner's Student Records connection will show any user who triggers it what the owner can see. Lumenvale's rule was that flows using delegated connectors either ran as a dedicated service account with deliberately limited rights in the target system, or used run-only users' own connections where the triggering user's identity mattered.
Sharing connectors and connections
Wiremu had assumed that sharing a connector shared access to the API. It does not. Sharing a custom connector with a user or group lets them see it and create their own connections from it; each connection still needs its own credentials. For the Student Records connector, Signe shared the connector with a security group of registrar staff and advisers, and each person signed in once with their own account. Nobody received anyone else's access.
Connections are a different matter. Some connection types can be shared with other users, and a shared connection lets them act with the credentials of the person who created it. Lumenvale's rule, which Rupert enforced in reviews, was never to share a connection that used a personal account. The few shared connections the college had, such as LedgerPoint's, belonged to service accounts, were documented in the solution's deployment notes, and were created by the people responsible for those accounts.
When sign-in fails
Authentication problems produce some of the least helpful errors in Power Platform, so Signe listed the ones Wiremu would meet. A redirect URI mismatch at sign-in means the address registered with the identity provider does not match the one the connector uses, often after switching to per-connector redirect URIs without updating the app registration. A consent error means the user is not allowed to grant the permission the connector asks for, and an Entra ID administrator must grant consent for the organization or adjust the requested scope. A connection marked as needing to be fixed usually means its refresh token was revoked or expired, for example after a password reset or a security policy change, and the owner must sign in again. And a 401 or 403 from the API itself, after a successful sign-in, means the token is valid but the API does not accept it for that operation, which points to the scope requested or the API's own permissions rather than to the connector.
The fastest way to tell these apart was the connector wizard's Test page, which shows the raw request and response. Wiremu learned to test each operation there with a fresh connection after any change to security settings, before touching a flow.
Least privilege in app registrations
Each app registration should ask for only the permissions it needs. The Student Records client asked for one delegated scope, read holds, and nothing else; when a later version of the connector added an operation to list a student's enrolled programs, a second scope was added to the API and requested by the client, and the change went through Dr. Ondaatje-Ruiz's privacy review because it widened what the connector could read. Client secrets had an expiry date, and the date was on Rupert's team calendar with a reminder a month ahead, because an expired secret breaks every connection at once.
LedgerPoint: an API key
LedgerPoint, the old finance system from MSBA-252, offered only API keys for its read-only reporting API. The key went in a header on every request. API key authentication is simple, and the connector's definition only says where the key goes; the key itself is typed in when a connection is created.
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"in": "header",
"name": "X-LedgerPoint-Key"
}
}The weakness of an API key is that it identifies a system, not a person. Every call through the connector looked to LedgerPoint like the same caller, so LedgerPoint could not apply per-user rules and its logs could not say who asked. Signe compensated in three ways. The key was issued for the reporting API only, which could read but never change data. It was stored in Azure Key Vault, readable only by Rupert's team, who entered it when creating the one shared connection in each finance environment; nobody else ever saw it. And the connector was used only by flows in the Finance Invoices solution, never shared with makers, so the question "who called" was answered by the flow run history.
The key was also rotated on a schedule. LedgerPoint allowed two active keys, so the team created a new key, updated the connection, confirmed the flows ran, and then revoked the old key. A rotation plan written before go-live meant nobody had to work one out in a hurry after a leak.
Parcelwise: generic OAuth 2.0
Parcelwise used its own OAuth 2.0 authorization server, so Wiremu chose the generic OAuth 2.0 identity provider. Parcelwise issued a client ID and secret for Lumenvale's application and documented its authorization and token URLs and the scopes for shipments and tracking. The connection signed in through Parcelwise's login page using the registrar's courier account, consented to the shipment scopes, and the platform stored the tokens and refreshed them as needed.
Only one connection was needed. Courier bookings were made by flows, not by individual clerks, and the courier account belonged to the registrar's office, not to a person. The connection was created by the registrar's service account during deployment and referenced by the flows through a connection reference. If a clerk left the college, nothing broke. If the service account's password changed, the tokens remained valid until Parcelwise revoked them, which was a reason to document how to recreate the connection.
Parcelwise offered a broad scope that included billing and account settings, and a narrower pair of scopes for shipments and tracking. Wiremu requested only the narrow pair in the connector's security settings. If the connection were ever misused, it could book and track parcels on the registrar's account, which was bad enough, but it could not change the account's billing details or add users. Signe asked him to write that reasoning into the connector's documentation page, so the next developer would not widen the scope for convenience.
| Connector | Authentication | Identity seen by the API | Who creates connections |
|---|---|---|---|
| Student Records | OAuth 2.0 with Microsoft Entra ID | The individual user, or a limited service account in flows | Each app user; deployment for flows |
| LedgerPoint | API key | The finance integration, as one caller | Rupert's team, once per environment |
| Parcelwise | Generic OAuth 2.0 | The registrar's courier account | The registrar service account during deployment |
On-premises APIs
Some APIs live inside the college network and cannot be reached from the internet. Custom connectors can call them through the on-premises data gateway, the same gateway Rupert's team ran for Power BI refreshes. The connector is marked as using the gateway, and each connection chooses a gateway. Windows authentication is available in this setup. Signe added a caution for lesson 8: custom code in a connector does not work with the gateway, so a connector that needs both must solve the problem another way, for example by moving the logic into the API.
Secrets and the definition
Signe was firm that no secret ever appeared in an OpenAPI definition, a policy, connector code or a repository. Client secrets were entered in the connector's security settings, and API keys at connection time. When the definition was exported to the repository, it contained the shape of the authentication but no credentials. A pull request review checked for anything that looked like a key, and the repository's secret scanning was on as a second line of defense.
Worked problem
Choosing authentication for a new connector
The library wants a connector to its new room booking service. The service supports Microsoft Entra ID sign-in and also issues API keys. Students will use a canvas app to book rooms, and the library wants to know who made each booking.
Show solution
- The service must know which student is booking, so the identity must be the individual user.
- Entra ID OAuth gives delegated access as the signed-in student; an API key would make every booking look like the same caller.
- Register the service's API and a client app for the connector in Entra ID, with a per-connector redirect URI.
- Share the connector with the app's users so each creates their own connection on first use.
- Keep the API key option unused, or use it only for a back-office flow that runs as the library, documented as such.
Answer: Microsoft Entra ID with delegated user connections in the app. The API key is suitable only for a clearly identified service flow.
Common mistakes
MistakeUsing one shared account for an API that applies per-user rules.
InsteadUse delegated OAuth so the API sees each user.
MistakeAssuming a flow runs as the person who triggered it.
InsteadCheck whose connections the flow uses and design for it.
MistakePutting a key or secret in the definition or the repository.
InsteadEnter secrets in security settings or at connection time; keep them in Key Vault.
MistakeIssuing an API key with write access when read is enough.
InsteadScope keys to the least access needed and plan rotation.
MistakeCombining connector code with the on-premises gateway.
InsteadCustom code does not work with the gateway; move logic into the API instead.
Summary and key terms
- Custom connectors support no authentication, basic, API key, OAuth 2.0 (generic and specific providers such as Microsoft Entra ID) and Windows authentication through a gateway.
- Entra ID OAuth uses app registrations for the API and the connector client, with a per-connector redirect URI, and gives delegated access as the user.
- Canvas apps use each user's connection; flows use their owner's or deployed connections unless configured otherwise.
- API keys identify a system, not a person, so they need narrow scope, safe storage and rotation.
- Secrets never belong in definitions, code or repositories.
- Connection
- A stored set of credentials or tokens created from a connector for one user or service account.
- App registration
- An Entra ID object that represents an application or API for OAuth.
- Delegated access
- Access in which the API acts on behalf of a signed-in user.
- Redirect URI
- The address an identity provider returns to after sign-in.
- Generic OAuth 2.0
- The connector setting for any standards-compliant OAuth 2.0 provider.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why could the student records system enforce its own rules for the Student Records connector?
Show answer
Delegated Entra ID access told it which user was calling.
Who does an automated cloud flow's connector call act as by default?
Show answer
The owner of the connection used by the flow, not the person who triggered it.
What does an API key identify?
Show answer
A system or application, not an individual user.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.