Back to skills
SKILL.md
1116 User Agent Social Sign On Ed635180
ASecurityOAuth 2.0 User-Agent flow combined with Social Sign-On (OIDC), where Salesforce acts as both the Authorization Provider (for the client) and the Relying Party (to the external OIDC Provider like Facebook, Google, etc.).
- 9 stars
- 0 votes
- 0 copies
- 0 views
- Added October 11, 2026
Works with
Security analysis
100/100npx -y skills add tools-only/X-Skills --skill 1116-user-agent-social-sign-on_ed635180 --agent claude-codeAre you the author of 1116 User Agent Social Sign On Ed635180?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tools-only-1116-user-agent-social-sign-on-ed635180)# User-Agent with Social Sign-On Flow Template
OAuth 2.0 User-Agent flow combined with Social Sign-On (OIDC), where Salesforce acts as both the Authorization Provider (for the client) and the Relying Party (to the external OIDC Provider like Facebook, Google, etc.).
## When to Use
- Mobile apps or SPAs requiring social login (Google, Facebook, etc.)
- When Salesforce is an intermediary between your app and social identity providers
- User-Agent flow (implicit-like) with external OIDC authentication
- Silent re-authentication scenarios (OP session cookies)
## Mermaid Template
```mermaid
%%{init: {'theme': 'base', 'themeVariables': {
'actorBkg': '#ddd6fe',
'actorTextColor': '#1f2937',
'actorBorder': '#6d28d9',
'signalColor': '#334155',
'signalTextColor': '#1f2937',
'noteBkgColor': '#f8fafc',
'noteTextColor': '#1f2937',
'noteBorderColor': '#334155'
}}}%%
sequenceDiagram
autonumber
box rgba(165,243,252,0.3) CLIENT
participant C as ๐ฑ Client<br/>(Mobile App)
end
box rgba(221,214,254,0.3) SALESFORCE
participant SF as โ๏ธ Salesforce<br/>(Auth Provider /<br/>Relying Party)
end
box rgba(254,215,170,0.3) OIDC PROVIDER
participant OP as ๐ OIDC Provider<br/>(Google/Facebook)
end
Note over C,OP: User-Agent Flow with Social Sign-On (OIDC)
%% Phase 1: Initial Access Token Request
C->>SF: ๐ค Access Token Request
Note over C,SF: GET /services/oauth2/authorize<br/>client_id, response_type=token<br/>redirect_uri, state, scope
SF->>SF: โ๏ธ Check for RP session
%% Phase 2: Redirect to OIDC Provider
SF->>C: ๐ฅ HTTP Redirect to OP
Note over SF,C: Redirect to OIDC authorize endpoint
C->>OP: ๐ค Auth Code Request
Note over C,OP: GET /authorize<br/>response_type=code<br/>redirect_uri=/services/authglobalcallback<br/>scope, state
%% Phase 3: Authentication at OP
OP->>OP: โ๏ธ Check for OP session
OP->>C: ๐ฅ Display Login Page
C->>OP: ๐ User authenticates
OP->>OP: โ๏ธ Validate credentials
OP->>C: ๐ฅ Display Consent Screen (first time only)
C->>OP: ๐ User grants consent
OP->>OP: โ๏ธ Generate authorization code
%% Phase 4: Return to Salesforce
OP->>C: ๐ฅ HTTP Redirect to Salesforce
Note over OP,C: Redirect to /services/authglobalcallback<br/>?code=OP_AUTH_CODE&state=...
C->>SF: ๐ค Deliver OP Auth Code
Note over C,SF: GET /services/authglobalcallback<br/>code=OP_AUTH_CODE, state
%% Phase 5: Salesforce exchanges code with OP
SF->>OP: ๐ค Access Token Request
Note over SF,OP: POST to OP Token Endpoint<br/>client_id, client_secret<br/>code, redirect_uri, state
OP->>OP: โ๏ธ Validate client & code
OP-->>SF: ๐ฅ Access Token Response
Note over OP,SF: id_token (JWT)<br/>access_token<br/>refresh_token
SF->>SF: ๐ Verify ID token signature
%% Phase 6: Optional UserInfo
rect rgba(248,250,252,0.5)
Note over SF,OP: Optional: UserInfo Endpoint
SF->>OP: ๐ค Request User Information
Note over SF,OP: POST /userinfo<br/>Authorization: Bearer ACCESS_TOKEN
OP-->>SF: ๐ฅ User Info Response
Note over OP,SF: User claims (email, name, etc.)
SF->>SF: ๐ Validate sub matches ID token
end
%% Phase 7: Salesforce User Provisioning
SF->>SF: โ๏ธ Invoke registration handler<br/>to create/update user
%% Phase 8: User Authorization for Salesforce
SF->>C: ๐ฅ Display Salesforce Consent
Note over SF,C: "App requests:<br/>โข API Access<br/>โข Refresh Token"
C->>SF: ๐ User grants Salesforce consent
%% Phase 9: Return tokens to Client
SF->>C: ๐ฅ Redirect to Client Callback
Note over SF,C: Redirect URI with:<br/>access_token (Salesforce)<br/>refresh_token<br/>instance_url
C->>C: โ๏ธ Store Salesforce tokens
%% Phase 10: API Usage
C->>SF: ๐ค Use Salesforce APIs
Note over C,SF: Authorization: Bearer SF_ACCESS_TOKEN
SF-->>C: โ
API Response
Note over C,SF: โ ๏ธ OP session cookie enables<br/>silent re-auth (~15 min)
```
## ASCII Fallback Template
```
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ Client โ โ Salesforce โ โ OIDC Provider โ
โ (Mobile App) โ โ (Auth/RP Server) โ โ (Google/Facebook) โ
โโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโโฌโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโ
โ โ โ
โ 1. Access Token Req โ โ
โ (response_type= โ โ
โ token) โ โ
โโโโโโโโโโโโโโโโโโโโโโโโ>โ โ
โ โ โ
โ 2. Redirect to OP โ โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ 3. Auth Code Request (response_type=code) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ>โ
โ โ โ
โ 4. Login Page โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ 5. Enter Credentials (authenticate) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ>โ
โ โ โ
โ 6. Consent Screen (first time) โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ 7. Grant Consent โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ>โ
โ โ โ
โ 8. Redirect with ?code=OP_AUTH_CODE โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ 9. Deliver OP Code โ โ
โโโโโโโโโโโโโโโโโโโโโโโโ>โ โ
โ โ โ
โ โ 10. POST Token Request โ
โ โ (code, secret) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ>โ
โ โ โ
โ โ 11. ID Token + Access โ
โ โ Token Response โ
โ โ<โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ โ [Optional: UserInfo] โ
โ โ 12. GET /userinfo โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ>โ
โ โ โ
โ โ 13. User Claims โ
โ โ<โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ โ 14. Registration Handler โ
โ โ (create/update user) โ
โ โโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โ<โโโโโโโโโโโโโ โ
โ โ โ
โ 15. SF Consent Screen โ โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ 16. Grant SF Consent โ โ
โโโโโโโโโโโโโโโโโโโโโโโโ>โ โ
โ โ โ
โ 17. Redirect with โ โ
โ SF Access Token โ โ
โ + Refresh Token โ โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ 18. Call SF APIs โ โ
โโโโโโโโโโโโโโโโโโโโโโโโ>โ โ
โ โ โ
โ 19. API Response โ
โ โ
โ<โโโโโโโโโโโโโโโโโโโโโโโโ โ
```
## Key Concepts
### Dual Role of Salesforce
| Role | Context | Responsibility |
|------|---------|----------------|
| **Authorization Provider** | OAuth flow with Client | Issues access tokens to your app |
| **Relying Party (RP)** | OIDC flow with Social Provider | Consumes ID tokens from Google/Facebook |
### Authentication Endpoints
| System | Endpoint | Purpose |
|--------|----------|---------|
| Salesforce Auth | `/services/oauth2/authorize` | Start User-Agent flow |
| Salesforce Callback | `/services/authglobalcallback` | Receive OP auth code |
| Salesforce Token | `/services/oauth2/token` | (Not used in User-Agent) |
| OP Authorization | Provider-specific | `/authorize` endpoint |
| OP Token | Provider-specific | Exchange code for tokens |
| OP UserInfo | Provider-specific | Get user profile claims |
## Security Considerations
1. **OP Session Cookies** - Enable silent re-authentication (~15 min intervals)
2. **ID Token Validation** - Salesforce verifies JWT signature from OP
3. **Sub Claim Matching** - UserInfo `sub` must match ID token `sub`
4. **State Parameter** - CSRF protection between all parties
5. **Registration Handler** - Custom Apex to map OP user to Salesforce User
## Salesforce Configuration
### Auth. Provider Setup
```
Setup โ Auth. Providers โ New
โโโ Provider Type: OpenID Connect (or specific: Google, Facebook)
โโโ Consumer Key: [From OP Developer Console]
โโโ Consumer Secret: [From OP Developer Console]
โโโ Authorize Endpoint: https://provider.com/authorize
โโโ Token Endpoint: https://provider.com/token
โโโ User Info Endpoint: https://provider.com/userinfo (optional)
โโโ Registration Handler: [Your Apex Class]
```
### Registration Handler Example
```apex
public class SocialLoginHandler implements Auth.RegistrationHandler {
public User createUser(Id portalId, Auth.UserData data) {
// Map social identity to Salesforce User
User u = new User();
u.Username = data.email + '.social';
u.Email = data.email;
u.FirstName = data.firstName;
u.LastName = data.lastName;
// ... additional mapping
return u;
}
public void updateUser(Id userId, Id portalId, Auth.UserData data) {
// Update existing user on subsequent logins
User u = [SELECT Id FROM User WHERE Id = :userId];
u.Email = data.email;
update u;
}
}
```
## Token Types
| Token | Issued By | Purpose |
|-------|-----------|---------|
| OP Auth Code | OIDC Provider | Short-lived, exchanged by SF |
| OP ID Token | OIDC Provider | JWT with user identity claims |
| OP Access Token | OIDC Provider | Used by SF to call OP UserInfo |
| SF Access Token | Salesforce | Used by Client to call SF APIs |
| SF Refresh Token | Salesforce | Long-lived, refresh SF access |
## Customization Points
Replace these placeholders:
- `CLIENT_ID` โ Your Connected App's Consumer Key
- `CALLBACK_URL` โ Your registered callback URL
- `OP_CLIENT_ID` โ Consumer Key from Social Provider
- `OP_CLIENT_SECRET` โ Consumer Secret from Social Provider
## Reference
- [Salesforce Identity: User-Agent with Social Sign-On](https://cloudsundial.com/salesforce-identity/user-agent-with-social-sign-on)
- [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html)
- [Salesforce Auth. Providers Documentation](https://help.salesforce.com/s/articleView?id=sf.sso_provider_openidconnect.htm)
Attribution
Comments
Loading commentsโฆ
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.