Skip to content

Commit f3f04b1

Browse files
authored
Merge pull request nhosoya#62 from skotchpine/with-apple-docs
write apple walkthrough
2 parents e3be57b + 64da734 commit f3f04b1

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,77 @@ Rails.application.config.middleware.use OmniAuth::Builder do
3434
end
3535
```
3636

37+
## Configuring "Sign In with Apple"
38+
39+
_other Sign In with Apple guides:_
40+
- ["How To" by janak amarasena (2019)](https://medium.com/identity-beyond-borders/how-to-configure-sign-in-with-apple-77c61e336003)
41+
- [the docs, by Apple](https://developer.apple.com/sign-in-with-apple/)
42+
43+
### Look out for the values you need for your config
44+
1. your domain and subdomains, something like: `myapp.com`, `www.myapp.com`
45+
2. your redirect uri, something like: `https://myapp.com/users/auth/apple/callback` (check `rails routes` to be sure)
46+
3. omniauth's "client id" will be Apple's "bundle id", something like: `com.myapp`
47+
4. you will get the "team id" value from Apple when you create your _**App Id**_, something like: `H000000B`
48+
5. Apple will give you a `.p8` file, which you'll use to GENERATE your `:pem` value
49+
50+
### Steps
51+
52+
1. Log into your [Apple Developer Account](https://idmsa.apple.com/IDMSWebAuth/signin?appIdKey=891bd3417a7776362562d2197f89480a8547b108fd934911bcbea0110d07f757&path=%2Faccount%2F&rv=1)
53+
(if you don't have one, you can [create one here](https://appleid.apple.com/account?appId=632&returnUrl=https%3A%2F%2Fdeveloper.apple.com%2Faccount%2F))
54+
55+
2. Get an App Id with the "Sign In with Apple" capability
56+
- go to your [Identifiers](https://developer.apple.com/account/resources/identifiers/list) list
57+
- [start a new Identifier](https://developer.apple.com/account/resources/identifiers/add/bundleId) by clicking on the + sign in the Identifiers List
58+
- select _**App IDs**_ and click _**continue**_
59+
- select _**App**_ and _**continue**_
60+
- enter a description and a bundle id
61+
- check the **_"Sign In with Apple"_** capability
62+
- save it
63+
64+
3. Get a Services Id (which we will use as our client id)
65+
- go to your [Identifiers](https://developer.apple.com/account/resources/identifiers/list) list
66+
- [start a new Identifier](https://developer.apple.com/account/resources/identifiers/add/bundleId) by clicking on the + sign in the Identifiers List
67+
- select _**Services IDs**_ and click _**continue**_
68+
- enter a description and a bundle id
69+
- make sure **_"Sign In with Apple"_** is checked, then click _**configure**_
70+
- make sure the Primary App ID matches the App ID you configured earlier
71+
- enter all the subdomains you might use (comma delimited):
72+
73+
example.com,www.example.com
74+
75+
- enter all the redirect URLS you might use (comma delimited):
76+
77+
https://example.com/users/auth/apple/callback,https://example.com/users/auth/apple/callback
78+
79+
- save the "Sign In with Apple" capability config and the Service Id
80+
81+
4. Get a Secret Key
82+
- go to your [Keys](https://developer.apple.com/account/resources/authkeys/list) list
83+
- [start a new Key](https://developer.apple.com/account/resources/authkeys/add) by clicking on the + sign in the Keys List
84+
- enter a name
85+
- make sure **_"Sign In with Apple"_** is checked, then click _**configure**_
86+
- make sure the Primary App ID matches the App ID you configured earlier
87+
- save the "Sign In with Apple" capability
88+
- click "continue" to finish the Key config (you will be prompted to _**Download Your Key**_)
89+
- Apple will give you a `.p8` file, keep it safe and secure (don't commit it).
90+
91+
### Mapping Apple Values to OmniAuth Values
92+
- your `:team_id` is in the top-right of your App Id config (aka _**App ID Prefix**_), it looks like: `H000000B`
93+
- your `:client_id` is in the top-right of your Services Id config (aka _**Identifier**_), it looks like: `com.example`
94+
- your `:key_id` is on the left side of your Key Details page, it looks like: `XYZ000000`
95+
- your `:pem` is the content of the `.p8` file you got from Apple, _**with an extra newline at the end**_
96+
97+
- example from a Devise config:
98+
99+
```ruby
100+
config.omniauth :apple, ENV['APPLE_SERVICE_BUNDLE_ID'], '', {
101+
scope: 'email name',
102+
team_id: ENV['APPLE_APP_ID_PREFIX'],
103+
key_id: ENV['APPLE_KEY_ID'],
104+
pem: ENV['APPLE_P8_FILE_CONTENT_WITH_EXTRA_NEWLINE']
105+
}
106+
```
107+
37108
## Contributing
38109

39110
Bug reports and pull requests are welcome on GitHub at https://github.com/nhosoya/omniauth-apple.

0 commit comments

Comments
 (0)