Skip to content

Commit

Permalink
readme: updated faq
Browse files Browse the repository at this point in the history
  • Loading branch information
sahat committed Feb 19, 2016
1 parent 14e807b commit bca18bc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ in the app *config* block.
- [Obtaining OAuth Keys](#obtaining-oauth-keys)
- [API Reference](#api-reference)
- [FAQ](#faq)
- [Can I change `redirectUri`` to something other than base URL?](#can-i-change-redirecturi-to-something-other-than-base-url)
- [How can I send a token in a format other than `Authorization: Bearer <token>?`](#how-can-i-send-a-token-in-a-format-other-than-authorization-bearer-token)
- [How can I avoid sending Authorization header on all HTTP requests?](#how-can-i-avoid-sending-authorization-header-on-all-http-requests)
- [Is there a way to dynamically change `localStorage` to `sessionStorage`?](#is-there-a-way-to-dynamically-change-localstorage-to-sessionstorage)
Expand Down Expand Up @@ -777,6 +778,28 @@ $auth.setStorageType('sessionStorage');

## FAQ

#### Can I change `redirectUri` to something other than base URL?

By default, `redirectUri` is set to `window.location.origin` (protocol, hostname, port number of a URL) for all OAuth providers. This `redirectUri` must match *exactly* the URL¹ specified in your OAuth app.

**Facebook (example)**
![](http://i.imgur.com/eaykgcZ.png)


However, you can set `redirectUri` to any URL you desire. For instance, you may follow the format of [Passport.js](http://passportjs.org/):
```js
// Note: Must be absolute path.
window.location.origin + /auth/facebook/facebook/callback
window.location.origin + /auth/facebook/google/callback
...
```

Using the example above, a popup window will be redirected to `http://localhost:3000/auth/facebook/callback?code=YOUR_AUTHORIZATION_CODE` after a successful Facebook authorization. To avoid potential 404 errors, create server routes for each `redirectUri` URL that return **200 OK**. Or alternatively, you may render a custom template with a loading spinner. For the moment, a popup will not stay long enough to see that custom template, due to 20ms interval polling, but in the future I may add support for overriding this polling interval value.

As far as Satellizer is concerned, it does not matter what is the value of `redirectUri` as long as it matches URL in your OAuth app settings. Satellizer's primary concern is to read URL query/hash parameters, then close a popup.

¹ **Note:** Depending on the OAuth provider, it may be called *Site URL*, *Callback URL*, *Redirect URL*, and so on.

#### How can I send a token in a format other than `Authorization: Bearer <token>`?
If you are unable to send a token to your server in the following format - `Authorization: Bearer <token>`, then use
**`$authProvider.authHeader`** and **`$authProvider.authToken`** config options to change the header format. The default values are `Authorization` and `Bearer`, respectively.
Expand Down Expand Up @@ -807,7 +830,6 @@ If you have configured everything correctly, chances are you running into the fo
Follow instructions on this [StackOverflow post](http://stackoverflow.com/questions/32631184/the-resource-could-not-be-loaded-because-the-app-transport-security-policy-requi) by adding `NSAppTransportSecurity` to *info.plist*. That should fix the problem.


## Credits

| Contribution | User
Expand Down

0 comments on commit bca18bc

Please sign in to comment.