Instagram returning “Matching code was not found or was already used” when using OAuth

前端 未结 8 1175
名媛妹妹
名媛妹妹 2021-01-30 07:00

I am trying to use the Instagram OAuth using the developer documentation at

https://www.instagram.com/developer/authentication/.

Step 1 and 2 a

8条回答
  •  遥遥无期
    2021-01-30 07:36

    I solved this by creating a service on the backend/server side that authorised the user.

    My backend API is a ruby on rails app. Here is a code snippet to understand.

      def token
        @response = Instagram.get_access_token(params[:code], redirect_uri: mobile_token_url)
        instagram_user = InstagramUserCreator.new(user_params)
        if instagram_user.find_or_create
          redirect_to "taddarmobileapp://?token=#{instagram_user.user.token}"
        else
          redirect_to 'taddarmobileapp://'
        end
      end
    

    I just store the token on the phone and use it to authorise the user to my backend API.

提交回复
热议问题