LoginSignup
1
0

More than 3 years have passed since last update.

[ReactNative] expoのAppAuthでOAuthを実装してみる

Last updated at Posted at 2019-12-18

What

expoのAppAuthの登場で、イジェクトなしでOAuth実装が非常に簡単になりました。
マイナーなSNSとの連携が必要な場合に非常に重宝しますね。

実装手順は以下
グーグルログインの場合


import * as AppAuth from "expo-app-auth";

 const config = {
    issuer: "https://accounts.google.com",
    clientId: "クライアント識別子"      
    scopes: ["profile"]
  };
 const tokenResponse = async () => {
   try {
     const authState = await AppAuth.authAsync(config);
     console.log(authState);
   } catch ({ message }) {
     alert(`${message}`); 
   } 
 };

これだけの手順でOAuthが実装できます。非常に簡単ですね。
AppAuth.authAsync()はtoken情報のみを返します。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0