-
Notifications
You must be signed in to change notification settings - Fork 278
Facebook, Instagram, Bitly, Pinterest and others
Thanh-Nhon NGUYEN edited this page Feb 5, 2020
·
2 revisions
Some sites don't return the required token_type
parameter in their token response.
You can tell if you're getting the error “No token type received, will not use the token”:
- Bitly
- LinkedIn does the same but needs even more special attention
- Medium
- Twitch
- Slack
There is a subclass for code grant flows that ignores the missing token type that you can use: OAuth2CodeGrantNoTokenType
.
For Instagram, Pinterest and Medium you also need to set oauth2.authConfig.secretInBody = true
(or use secret_in_body
in your settings dict) because it expects the client secret in the request body, not the Authorization header.
let oauth2 = OAuth2CodeGrantNoTokenType(settings: [
"client_id": "<app_id>",
"client_secret": "<app_secret>",
"authorize_uri": "https://graph.facebook.com/oauth/authorize",
"token_uri": "https://graph.facebook.com/oauth/access_token",
"response_type": "token",
"scope": "email",
"secret_in_body": true,
"redirect_uris": ["fb\(<app_id>)://authorize/"] // The "/" at the end is mandatory
])
Make sure to register your URL type with URL Schemes as fb<app_id>
and Bundle ID on https://developers.facebook.com/ exactly the same (fb<app_id>
)
let oauth2 = OAuth2CodeGrantNoTokenType(settings: [
"client_id": "***",
"client_secret": "***",
"authorize_uri": "https://api.instagram.com/oauth/authorize",
"token_uri": "https://api.instagram.com/oauth/access_token",
"response_type": "code",
"redirect_uris": ["myapp://oauth/callback"],
"keychain": false,
"title": "InstagramViwer"
] as OAuth2JSON)
let oauth2 = OAuth2CodeGrantNoTokenType(settings: [
"client_id": "***",
"client_secret": "***",
"authorize_uri": "https://api.pinterest.com/oauth/",
"token_uri": "https://api.pinterest.com/v1/oauth/token",
"redirect_uris": ["***"],
"scope": "read_public",
"keychain": false,
"verbose": true,
] as OAuth2JSON)
let oauth2 = OAuth2CodeGrantNoTokenType(settings: [
"client_id": "***",
"client_secret": "***",
"authorize_uri": "https://medium.com/m/oauth/authorize",
"token_uri": "https://api.medium.com/v1/tokens",
"redirect_uris": ["***"],
"scope": "basicProfile",
"secret_in_body": true,
"keychain": false,
"verbose": true,
] as OAuth2JSON)