Oct 21~24, 2023【晚秋の贅沢な山旅 PART②】黒部峽谷♡下之廊下|日本北阿爾卑斯山秘境健行+野營+秘湯溫泉 DAY 1(黒部水壩〜下之廊下〜阿曾原溫泉)

圖片
今天是這趟四天三夜秋季山旅的第二天,昨天在信濃大町悠閒度過了半天,今天終於要進入黑部峽谷山區了。原本是預計早上6點15分,要從信濃大町車站前,乘坐第一班巴士前往 扇沢 ,但是旅館客房太溫暖,不小心睡過頭,等到自然醒時,看了手機已經早上6點了。 這時就算再怎麼快速收拾背包衝到車站也趕不上6點15分的巴士了。雖然還有下一班巴士可以搭,但是今天的路程有點遠,得走上20公里,加上紅葉季節,如果太晚抵達露營場,可能會找不到位置紮營,所以我想還是儘早出發比較好。幸好車站前有計程車可以利用,只是必須多花幾千塊日幣消災就是了。 在觀光季節,最早一班由 扇沢 開往 黒部ダム ( 黑部水壩 )的巴士是早上7點30分發車,所以只要需抓個50分鐘的乘車跟買票時間,大概早上6點40分左右,從大町車站前搭上計程車就沒問題了。 洗漱完畢,整理好背包後,將房間鑰匙放回旅館櫃檯的籃子裡,然後走路到車站前面,叫一輛計程車前往 扇沢 (車資大約8000日幣上下)。走在路上可以看見遠處三千公尺級的高山,都已經覆上了新雪,預告著今年的雪季即將到來。 早上7點左右抵達 扇沢 ,買了一張前往 黑部水壩 的單程電氣巴士車票(1,800日幣),然後將登山計畫書投遞進箱子裡,走上二樓排隊等待搭車。果然不愧是紅葉季節,車站二樓裡面,整整四排的排隊區,已經排滿了登山客和觀光客。 扇沢 其實就是 立山黑部阿爾卑斯路線 的長野側起點,是觀光客很喜歡造訪的地方,只是一般觀光客不會曉得,站在黑部水壩頂部欣賞放水時,在那 日本規模第一 的水壩後方之溪谷深處,竟然隱藏著一條少為人知的登山步道。 相關參考連結 下ノ廊下を含む活動日記一覧(YAMAP) 登山ルート情報 - 阿曽原温泉小屋 立山黒部アルペンルート|公式サイト アルピコ交通|路線バス 扇沢線 くろよん(黒部ダム)ーその手に未来をー|関西電力 2021年の番組~最後の秘境・黒部源流紀行【小椋久美子が黒部川の“最初の一滴”を目指す旅】 【下の廊下】黒部峡谷の断崖絶壁を命懸けで歩く(前編) 【下の廊下】落ちたら終わりの絶景登山道(後編) 【テント泊登山】断崖絶壁30kmの道、黒部峡谷の歴史を歩く|旧日電歩道-下ノ廊下-水平歩道 黒部源流と大峡谷( 圖片來源 ) 雖然排隊人潮很多,但是早上7點半準時檢票上車,群眾也非常有秩序和效率的往前進,似乎連一點時間也沒有耽誤到就準時發車了,日...

FbGraph + OmniAuth + Facebook Graph API on Rails application

OAuth is often described as a 'valet key for the web'. In the same way as a valet key gives restricted access to a car, allowing the valet to drive it but not open the trunk or glovebox, OAuth allows a client application restricted access to your data at a resource server via tokens issued by an authorization server in response to your access grant.

Facebook Platform uses the OAuth 2.0 protocol for authentication and authorization. Suppose your Rails application allows users to share content with their Facebook friends. To support this, a connection needs to be established between a user's local account and her Facebook account. Once established, a Facebook instance can be obtained and used to post content to the user's wall. The basic idea is to store the access_token during an OAuth2 login process and later on use the token to fetch more data.

The last days I was working on letting user sign-up/sign-in using Facebook account. I'm planning to integrate some social features into my ongoing Rails project. Previously I was working with Facebooker, an awesome Rails plugin that did a great job for my previous project, however it seemed not support the latest Facebook Graph API. Thought I found a new solution.

OmniAuth is an open source project which provides support for many of the main providers out there: twitter, facebook, foursquare, and many more. In addition, OmniAuth is designed in such a way that it is very easy to implement custom strategies---interchangable logic which encapsulates the steps required to successfully authenticate with an Oauth2 provider.

OmniAuth relies on the request and callback sequence as defined in OAuth2 specification. OmniAuth extracts away a lot of the complexity of working with OAuth, so we can skip all of that information and focus on just what we need to. The diagram below depicts how OmniAuth handles the request and callback sequence:


The request phase of the OAuth dance typically redirects to a providers website which prompts the user to enter their credentials with the provider calling back to Omniauth with a success or failure message.

There is a couple of great screencasts on how to integrate Omniauth to Devise using Rails 3 and allow Facebook, Twitter, etc. authentications. In this post, I'm going to show you how to connect to the Facebook platform using FbGraph along with Omniauth to retrieve a list of records and post message to the facebook wall via its Graph API. For this example, I'm using Rails 2.3.8 on my Mac. But I strongly encourage you to start with Rails 3.

First, we would need a migration to store a permanent Facebook token for offline access:
$ script/generate migration AddFacebookTokenToUsers


Add the following to your config/environment.rb

Next, in your initializer, usually config/initializer/omniauth.rb, request additional permissions, we need to tell Omniauth to retrieve more Facebook permissions in order to have offline access, Wall, etc. You can define the ones you need from Facebook permissions API pages, but here is my setting:

If you get this error message when you're trying to run your Rails server: 
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.8
The problem was most likely bad library management, if you don't have libxml2 in the Cellar directory on OSX, you can install it to this using homebrew:


Now, lets get to the application code changes. In the application controller we define the facebook_user like this:


In the routes.rb we add following routes:


Next, edit your fb_oauth_controller.rb add the callback method:


Callback is the action that is called after the authorization. The access_token is not restricted with time unless Facebook changes their policy and make them expire after a particular period of time, and is used later for interacting with Facebook.. To understand how it all works, read about Facebook permissions, the Graph API. The /auth/facebook url is invoked first. This redirects the user to Facebook where the user gets the permission prompt, to allow your application to access the users information. If everything works you should have the full authentication workflow going!



You can also use this URL to get a permanent access_token:


Facebook uses the OAuth 2.0 protocol for user authentication and application authorization. Following are the steps required to obtain an access token:

(a) Redirect the user to https://graph.facebook.com/oauth/authorize and pass the application id and post authorize callback URL as parameters to this API.
(b) User enters their credential in the above Facebook URL and after successfully authorizing the application, Facebook would redirect the user to the authorize callback url along with a verification string in the argument code, which can be exchanged for an OAuth access token.
(c) Generate an access token using the above verification code by fetching https://graph.facebook.com/oauth/access_token

Once the access token is obtained, all further communications to Facebook will only require this token instead of the user’s credentials. 


You can modify the callback method to integrate Facebook connect with your authentication system (Allow your users to sign up/sign in with their Facebook account). See the example below:


Now the application retrieves email and also you have an access to Facebook Graph API. For instance, to post something on Facebook wall you can:




Enjoy! hope this helps you :)


熱門文章

Mar 2025【桃園大溪】金面山(小百岳 No.021)、金山面山健行|阮家土雞城起登

Sep 2024 晚夏的黑部源流4泊5日山旅 PART ①【溪流登攀&溫泉三昧】赤木沢~五郎沢~祖父沢遡行&雲ノ平~高天原~裏銀座縱走(旅途的開始)

Oct 21~24, 2023【晚秋の贅沢な山旅 PART②】黒部峽谷♡下之廊下|日本北阿爾卑斯山秘境健行+野營+秘湯溫泉 DAY 1(黒部水壩〜下之廊下〜阿曾原溫泉)

Mar 12, 2022【重機一日遊】走北橫至宜蘭,經梨山、武嶺下埔里,再走台三線回桃園|16小時的半圈環島

Sep 2025【新北雙溪】蝙蝠山、苕谷瀑布、百二階古道O形|山頂有360度展望,但之後的路線蜘蛛絲有點多

Jun 2025【彰化員林】月光山舍土雞料理景觀餐廳(寵物友善餐廳)|員林藤山步道散步

Aug 2025【新北金山】循竹子山古道(前段)造訪阿里磅瀑布|陽明山第一大瀑布|冷門山徑

2019, July 7~8【中國山東】老司機帶你攀登72位古代帝王曾登臨朝拜,以五嶽獨尊名揚天下的泰山(歷史典故+遊覽路線+遊記+照片)

2019 Aug 16~18【福建南平】中國世界遺產~福建武夷山遊記。登天遊峰、臨九曲溪、品大紅袍

日本の登山の歷史

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *