Skip to content
Back to skills

1116 User Agent Social Sign On Ed635180

ASecurity

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.).

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
securitygoapisecuritydocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 1116-user-agent-social-sign-on_ed635180 --agent claude-code

Installs into .claude/skills of the current project.

Are 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.

Security grade badge for 1116 User Agent Social Sign On Ed635180
[![Security: A โ€” Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1116-user-agent-social-sign-on-ed635180/badge)](https://www.skillsdirectory.com/skills/tools-only-1116-user-agent-social-sign-on-ed635180)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# 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

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading commentsโ€ฆ

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.