Identity and access OAuth 2.0 4 min read
What is OAuth 2.0?
PrintShop, a photo-printing app, wants the pictures in your photo service. Do you have to give it your password?
-
You approve on the service’s own page
PrintShop sends you to the photo service’s own sign-in page, with a list of what it wants: here, to see your photos. You sign in there, so PrintShop never sees your password.
Once you approve, the service hands PrintShop an access token. It’s limited to what you approved, and it expires. The Photos API checks the token on every request.
PrintShop sends you to the photo service’s sign-in page asking to read your photos. You sign in and approve there. The service gives PrintShop an access token, which PrintShop sends to the Photos API to get your album.
Your password only ever goes to the photo service. In short The app gets a limited key that expires, never your password.
-
Read what it’s asking for
The approval page lists the scopes the app wants. A printing app needs to see your photos and albums, maybe your name and profile picture. That’s about it.
Delete your photos, read your email, manage your contacts: none of that is needed to print a picture. If an app asks for it, say no.
Like a valet key: it starts the car, but won’t open the glovebox. In short Grant only the scopes the app needs for its job.
What an access token doesn’t prove
An access token says what an app may do at an API. It isn’t proof of who the user is, and it might have been issued to a different app.
Apps that sign people in with “I got an access token for this user” can be fooled. For sign-in, use OIDC: it adds an ID token made for exactly that.
Keep this
OAuth hands an app a limited key, not your password. Grant only the scopes it needs.
An access token says what an app may do at an API. It isn’t proof of who you are; for sign-in, use OIDC.- Delegation
- You let an app act for you at another service.
- Scope
- What the app may do, like read photos.
- Access token
- The limited, expiring key the app uses.
- Not sign-in
- Identity is OIDC’s job, built on top.
Questions worth carrying
How do I take back an app’s access?
Go to the service’s security or connected-apps page and revoke it. The app’s tokens stop working, and your password never changed hands.
Why do apps get a code first, then a token?
The code travels through your browser, which is easy to snoop on. The app swaps it for the token directly with the service, and PKCE makes sure only the same app can swap it.