나는이 코코아 포드를 사용하여 OAuth 2.0을 사용하는 iPad 앱을 만들려고합니다 : https://github.com/OAuthSwift/OAuthSwift. 이 파이어베이스 튜토리얼 (https://firebase.google.com/docs/auth/ios/custom-auth)을보고 있습니다 만, 조금 혼란 스럽습니다.Firebase : OAuth 토큰이 연결된 계정을 어떻게 알 수 있습니까?
oauthswift = OAuth2Swift(
consumerKey: "********",
consumerSecret: "********",
authorizeUrl: "https://api.instagram.com/oauth/authorize",
responseType: "token"
)
let handle = oauthswift.authorize(
withCallbackURL: URL(string: "oauth-swift://oauth-callback/instagram")!,
scope: "likes+comments", state:"INSTAGRAM",
success: { credential, response, parameters in
print(credential.oauth_token)
FIRAuth.auth()?.signIn(withCustomToken: credential.oauth_token ?? "") { (user, error) in
// ...
}
},
failure: { error in
print(error.localizedDescription)
}
)
어떻게 그 토큰이 토큰은 각 장치에 대한 무작위 다른 경우에 어떻게 연관되어 계정을 알고 중포 기지 것 :
는이 코드를 감안할 때? 토큰을 계정에 연결하는 방법을 모르겠습니다. 사용자 이름이 [email protected]
이고 비밀번호가 blah123
이고 oauth_token이 123abc
인 Instagram에 로그인 한 경우 123abc
은 123abc
이 [email protected]
에 내 firebase 계정에 연결되어 있다는 것을 어떻게 알 수 있습니까?
나는 개념 중 하나를 오해하고있는 것처럼 느껴집니다.
그래서'withCallbackURL'을'myserver.com/something'으로 설정하고 내 서버에서 커스텀 토큰을 만든 다음'success' 콜백에서 내 서버에이 요청을 가져 오기 위해 다른 요청을해야합니다 Instance에 의해 반환 된 oauth_token을 사용하는 사용자 정의 토큰? – Edmund
Firebase Admin SDK 나 서버 측에서 자신을 사용하여 사용자 정의 된 서명 JWT 토큰을 생성하고이를 서버 측에서 'FIRAuth.auth()? signIn (withCustomToken :')으로 전달해야합니다. 사용자 정의 JWT는 사용자의 uid '(Instagram 또는 내부 하나), 이는 사용자를 Firebase에 고유하게 식별하고 (다른 플랫폼 간 상호 참조를 허용합니다),이 링크는 상당히 잘 설명합니다 : https://firebase.google.com/docs/auth/admin/create-custom-tokens – d3vtoolsmith