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

圖片
今年晚夏的山旅,我前往了日本北阿爾卑斯山脈黑部源流域進行為期五天四夜的溪流登攀+登山縱走行程。黑部川源流一帶的山域,雖然過去幾年已造訪過多次,不過這回是第一次在日本進行溪流登攀(日本叫「 沢登り 」),而且是在我特愛的黑部川流域,讓我對黑部源流域有了更進一步的認識。 此行也順路造訪了五年前就計畫要去,但是因爲颱風而沒能去成的「 雲ノ平 」,以及有「 日本第一遠的溫泉 」之稱的秘湯「 高天原溫泉 」泡湯。然後還走了去年因為天氣惡劣而沒能走的「 裏銀座縱走路線 」下山,完成這趟縱橫黑部源流域,總距離50幾公里的溪流登攀和登山旅行。 黑部川 (日語:黒部川/くろべがわ)是日本富山縣東部的一級河川,為黑部川水系的本流,它被列為富山縣的七大河流之一,其他六條河流分別是片貝川、早月川、常願寺川、神通川、莊川和小矢部川。 黑部川 大部分蜿蜒於深山內,形成十分陡峭的黑部峽谷,如果想親身感受黑部峽谷的壯闊,走一趟 下ノ廊下 和 水平步道 ,絕對是畢生難忘的體驗。 下圖為黑部川水系流域的示意圖,從海拔2924米的 鷲羽岳 降下的的最初的一滴水,流經 奧ノ廊下 、 上ノ廊下 、 下ノ廊下 ,並匯聚了黑部山區眾多支流的溪水後,向北奔流而下,然後流入富山灣,最後進入日本海。 下圖是這趟山旅所進行的溪流登攀(沢登り)的區域,包括 赤木沢 、 五郎沢 、 祖父沢 等黑部川支流,主要位於黑部川的源頭,尤其是赤木沢,更有著「 日本第一美溪 」之稱號。 黑部源流…這幾個字對登山者來說有著特殊的魔力。人跡罕至的秘境,峽谷綿延的 上ノ廊下 ,激流沖刷岩石的 下ノ廊下 ,源頭的雲ノ平瑞士庭園等。在這黑部源流的一隅,一條溫柔的小溪緩緩流入。赤木沢與黑部川本流交匯處的絕美景色,展現了大自然鬼斧神工的美麗,在陽光照耀下的溪流和深潭,呈現出豐富的色彩變化,其美景宛如天國一般。 下圖是我這趟五天四夜的山旅,所行經過的整個路線(使用 YAMAP 紀錄),從富山縣的 折立登山口 入山,溯行黑部源流域的多個溪流(黑部川上游的支流),並順訪 雲ノ平 和 高天原溫泉 後,再走 裏銀座縱走路 ,由高瀨湖下山,總距離約53.6公里(不過在 Sports Tracker 上面的紀錄卻是63.3公里,不知道哪個才是正確的)。 這趟山旅的途中,依序住宿 藥師沢小屋 、 黑部五郎小屋 、 雲ノ平山莊 、 水晶小屋 ,這些都是以前沒有住過...

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 :)


熱門文章

Jun 2025【苗栗獅潭】苗栗百大必訪步道|小百岳仙山|靈洞宮起登,雲霧繚繞,仙氣滿滿

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

May 2023【雲林古坑】 負離子濃度達都市40倍/漫步木馬古道/順訪雲嶺之丘/山合苑喝咖啡/秋田犬

Jan 2025【日本東北】溫泉三昧之旅② 在大雪飄落的雪國,追尋秘湯之宿與極上美食(仙台~品嚐極上米澤牛&奧羽的百年藥湯-鎌先溫泉)

Oct 21~24, 2023【晚秋の贅沢な山旅 PART①】從名古屋搭車至長野|在北阿爾卑斯山麓的文藝小鎮信濃大町散步、品嚐美味的炸豬排定食和咖啡

Sep 26, 2023【夢と浪漫 伊藤新道①】探訪日本北阿爾卑斯山脈黑部源流域一條封閉了40年的古道「伊藤新道」―Day1―高瀨溪谷健行・從七倉登山口前往湯俣溫泉晴嵐莊

2019.10.9~13【令和元年の紅葉の山旅へ PART①】秋の贅沢、黒部川の源流へ北アルプス深部を縦走5日間!Day0、Day1(前泊、折立~藥師岳山莊)

Jun 2025【新北林口】觀音山硬漢嶺步道O型散步(龍女岩、硬漢嶺、鷹仔尖)

Jan 2025【苗栗泰安】泰安警光山莊泡湯&彰化CP值極高的日本料理|沐藏料理所X海龍王|彰化板前料理 ♨️🍁🥢🍲

Jun 2025【桃園蘆竹】全台百大必訪步道|羊稠森林步道|秋田犬散步|羊稠步道甲蟲季即將登場

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *